Github Actions Integration
Github Action Integration Setup Guide for API Scanner
Overview
This guide walks you through integrating API Scanner with your github actions workflow to automatically scan APIs for security vulnerabilities during your build process.
What You Can Achieve
- Automated Security Scanning: Run security scans automatically during your github actions workflow builds
- Pipeline Control: Choose whether to block or continue builds based on scan results
- Continuous Monitoring: Automatically scan newly added APIs in your collection
- Real-time Results: Get immediate feedback on your API security posture
Before You Start
Make sure you have the following ready:
Required Setup
- Active Github Actions workflow: You need a working github actions workflow setup.
- API Collection in GitHub: Your API collection file should be stored in a GitHub repository that gets updated with new APIs
- Existing API Scanner Collection: You must have the same API collection already set up in API Scanner with proper authentication configured
- Include refresh tokens if your authentication tokens have short expiry times
- Running API Scanner: The API Scanner server must be running during pipeline builds
Step-by-Step Integration Process
Step 1: Configure Integration Settings
1.Access Integration Module
- Open API Scanner in your browser
- Navigate to the Integration section
2.Select github actions Integration
- From the available integrations list, click on github actions
3.Fill in Connection Details
4.Enter the following information:
Field | Description | Example |
Integration Title | A descriptive name for this integration | "Production API Security Scan" |
User Name | Your name or the integration creator's name | "John Doe" |
Host URL | The URL where API Scanner is hosted | http://103.81.38.252:9090/ or http://localhost:9090/ |
Repository URL | Your GitHub repository URL containing the API collection | https://github.com/yourorg/api-collections |
Branch Name | The branch where your API collection is stored | main, develop, or hotfix |
API Collection File Name | The exact filename of your API collection | Hair Store API-06-09-2024.json |
5.Save Configuration
- Click the "Create Connection" button to save your settings
Step 2: Configure Pipeline Behavior
1.Select Your Collection
- Choose the API collection you want to integrate with github actions workflow from the "Validate Collection" dropdown
2.Choose Pipeline Action
Decide how the pipeline should behave when vulnerabilities are found:
Option A: Do Not Block Pipeline
- The security scan will run, but the pipeline will continue regardless of results
- Use this for monitoring purposes without interrupting deployments
Option B: Block Pipeline
- The pipeline will stop if vulnerabilities meet your specified criteria
- Set vulnerability thresholds for different severity levels:
- Critical: Enter number of critical vulnerabilities that will block the pipeline
- High: Enter number of high-severity vulnerabilities that will block the pipeline
- Medium: Enter number of medium-severity vulnerabilities that will block the pipeline
- Low: Enter number of low-severity vulnerabilities that will block the pipeline
Example: Setting "Critical > 0" will block the pipeline if even 1 critical vulnerability is found.
6.Generate Integration Script
- Click the "Generate Script" button
- Copy the generated script to your clipboard
Step 3: Add Script to actions workflow
1.Open GitHub Repo
- Navigate to your GitHub actions tab from the top bar
- Create a new workflow or open existing workflow
2.Update Pipeline Script
- Add the copied script from Step 2 to your existing pipeline script
3.Save Changes
- Click "Save" to apply the pipeline updates and commit the file.
Integration Complete!
Your GitHub actions workflow pipeline is now configured to automatically scan your APIs for security vulnerabilities. Here's what happens next:
- Automatic Scanning: Every pipeline build will trigger an API security scan
- Real-time Feedback: You'll receive immediate results about any vulnerabilities found
- Controlled Deployment: Based on your settings, the pipeline will either continue or stop depending on scan results
Troubleshooting Tips
- API Scanner Not Running: Ensure the API Scanner server is active before starting any pipeline builds.
- Authentication Issues: Verify that your API collection in API Scanner has proper authentication setup.
- File Not Found: Double-check that the API collection filename exactly matches what's in your GitHub repository.
- Connection Problems: Confirm that the Host URL is accessible from your actions workflow account.
Need Help?
If you encounter any issues during setup, verify that all prerequisite requirements are met and that the API Scanner server is running and accessible from your actions workflow environment.