Whitespots Wiki
Login
  • Home
  • πŸ”¦Auditor
    • πŸ“₯Deployment
      • Installation
      • Update
    • 🎯Features
      • πŸš€Run Audit
        • AppSec Portal cooperation
        • Direct use of Auditor
      • βš™οΈSettings
        • AppSec Portal cooperation
        • Direct use of the Auditor
          • Cleaner
          • Docker Credentials
          • Workers
          • Personalization
        • Jobs
          • Technical Jobs
          • Scanner Jobs
          • Job configuration
    • πŸ—’οΈRelease notes
    • 🩼Maintenance
  • πŸ–₯️AppSec Portal
    • πŸ“₯Deployment
      • License obtaining
      • Installation
      • Get started with the AppSec Portal
        • Π‘onfiguration options
      • Update
      • Accessing the AppSec Portal API Endpoints
      • Database transfer guide
      • FAQ: typical errors in deployment process
    • βš™οΈPost install Configuration
    • 🎯Features
      • 🎣Auto Validator
        • Rule creation
        • Rules view
      • Deduplicator
        • βš™οΈBasic deduplicator rules
        • βš™οΈAdvance Deduplicator rules
      • πŸ”¦Vulnerability discovery
        • βœ”οΈAudits
        • βš™οΈAuditor settings
          • Auditor config
          • Sequences
            • Sequences creating
            • Sequences setting
        • πŸ”ŽRun audit
          • Run Audit Manually
          • Scheduled Audit Run
      • 🎯Recommendations
      • Security Metrics
        • Severity Statistics Dashboard
        • WRT (Weighted Risk Trend)
        • How to work with WRT (for team leads)
        • Metrics settings
          • SLA
        • CVSS
          • CVSS Rule
      • Custom Reports
      • πŸ“ˆActive tasks
      • 🧺Asset management
        • How to import repositories from version control
        • Default product
        • Adding a product asset
        • Asset Transfer Between Products
      • πŸ•·οΈFindings view
        • All findings view
        • Grouped findings as a result of
        • Grouping of findings into groups
        • Available bulk actions
        • Viewing specific findings
        • Usable filters and easy sorting
      • πŸ“ŠJira
        • Jira integration configuration
        • Setting up Jira webhook
      • πŸ‘ΎMove from DefectDojo
      • πŸ”¬Scanners
        • πŸ”ŒImporting reports from scanners to AppSec Portal
          • πŸ–οΈManual Import using Report File
          • Importing reports via Terminal using a Report File
          • Importing reports via Lambda Function using a Report File
        • Scanner description
          • Code Scanners
            • Bandit
            • Brakeman
            • Checkov
            • CodeQL
            • ESLint
            • Gemnasium
            • Gosec
            • Hadolint
            • KICS
            • PHPCodeSniffer
            • Retire.js
            • Semgrep
            • SpotBugs
            • Terrascan
          • Secret Scanners
            • Gitleaks
            • Trufflehog3
          • Image and code dependency Scanners
            • Trivy
            • Trivy vulners.com plugin
            • Snyk
          • Web Scanners
            • Arachni Scan
            • Acunetix
            • Burp Enterprise Scan
            • OWASP Zap
          • Infrastructure Scanners
            • AWS Security Hub Scan
              • Importing reports via AWS Lambda Function within AWS Security Hub
            • Prowler
            • Subfinder
            • Nessus
            • Nuclei
          • Mobile Security Scanners
            • MobSFScan
          • Other Scanners
            • Dependency-Track
            • Whitespots Portal
      • πŸ“¦Working with products
        • Product Creation
        • Product options
        • Finding groups
        • Risk assessment
        • Product Asset
    • πŸ› οΈGeneral Portal settings
      • Version Control Integration
      • Profile
      • Managing user roles and access control
        • User management
        • Creating and editing roles
      • SSO settings
        • GitLab SSO
        • Microsoft SSO
        • Okta SSO
      • Scanner settings
        • Auto Closer
        • Group findings by
        • Custom Jira description
        • Custom severity mapping
        • Auditor Job Config
      • Notification settings
        • Integration
        • Criteria & Schedule
        • Status change notification
        • Manage notification schedule
      • Repository Link Configs
      • CWE list
      • Tag screen
    • πŸ—’οΈRelease notes
  • To be described
    • Documentation backlog
Powered by GitBook
On this page
  • Step 1: Integration Preparation
  • Step 2: Creating AWS Lambda Function
  • Step 3: Running the Function

Was this helpful?

  1. AppSec Portal
  2. Features
  3. Scanners
  4. Scanner description
  5. Infrastructure Scanners
  6. AWS Security Hub Scan

Importing reports via AWS Lambda Function within AWS Security Hub

To send scanning data to AWS Security Hub on Appsec Portal

PreviousAWS Security Hub ScanNextProwler

Last updated 1 year ago

Was this helpful?

This is achieved using an AWS Lambda function written in Python. The function extracts an API key from AWS Secrets Manager, constructs a request with scanning data, and sends it to the specified Appsec Portal address.

Step 1: Integration Preparation

  1. AWS Lambda: Ensure you have a configured and functioning AWS Lambda function

  2. AWS Secrets Manager: Create a secret in AWS Secrets Manager containing the for accessing Appsec Portal. Ensure you have read access rights to this secret

Step 2: Creating AWS Lambda Function

  1. Navigate to the AWS Lambda console

  2. Create a new Lambda function according to your requirements

  3. Make sure the function has the necessary permissions to access Secrets Manager and make HTTP requests

  4. Insert the code into the code editor of your function:

import json
import boto3
import urllib.request
import urllib3


def lambda_handler(event, context):
    
    # Fetch Appsec Portal API key from AWS Secrets Manager
    client_sm = boto3.client('secretsmanager')
    appsec_portal_secret_raw = client_sm.get_secret_value(
        SecretId="<secret_name>"
    )
    appsec_portal_api_json = json.loads(appsec_portal_secret_raw["SecretString"])
    appsec_portal_api_token = "Token " + appsec_portal_api_json['key']
    
    while True:
        try:
            url = 'https://<portal_address>/api/v1/scan/import/'
            body = {
                "file": ("event.json", json.dumps(event)),
                "product_name": "AWS",
                "product_type": "AWS",
                "scanner_name": "AWS Security Hub Scan"
            }
            data, header = urllib3.encode_multipart_formdata(body)
            r = urllib.request.Request(url, data=data)
            r.add_header('Authorization', appsec_portal_api_token)
            r.add_header('Content-Type', header)
            response = urllib.request.urlopen(r)
            print(response.getcode())
        except Exception as e:
            raise e
        break
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
    }

Replace "<secret_name>" with the name of the secret in AWS Secrets Manager containing your API key for Appsec Portal

Replace "<portal_address>" with the address of your Appsec Portal

  1. Save the changes made to the function

Step 3: Running the Function

  1. In the "Test" section of the AWS Lambda console, create a test event with content similar to your report to test the function

  2. If the function passes testing successfully, publish it

Congratulations! Your function is now ready to send reports to Appsec Portal

πŸ–₯️
🎯
πŸ”¬
API key