Skip to content

Commit 7e46fb8

Browse files
committed
Automate RapiDAST seed URL generation and config update
Adds a script to generate API endpoint URLs for RapiDAST scanning based on MCP server configuration. Updates the workflow to run this script and display generated URLs. Modifies rapidast-config.yml to import URLs from the generated file and removes hardcoded spider endpoints for improved flexibility and coverage.
1 parent f60109c commit 7e46fb8

3 files changed

Lines changed: 90 additions & 10 deletions

File tree

.github/workflows/rapidast.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,19 @@ jobs:
102102
fi
103103
echo "Final RapiDAST configuration:"
104104
cat rapidast-config.yml
105+
- name: Generate seed URLs for scanning
106+
run: node scripts/generate-rapidast-urls.cjs
107+
env:
108+
CONFIG_FILE: aap-mcp.yaml
109+
OUTPUT_FILE: rapidast-urls.txt
110+
BASE_URL: http://localhost:3000
111+
112+
- name: Display generated URLs
113+
run: |
114+
echo "Generated URLs for scanning:"
115+
head -20 rapidast-urls.txt
116+
echo "Total URLs: $(wc -l < rapidast-urls.txt)"
117+
105118
- name: Create results directory
106119
run: |
107120
mkdir -p results

rapidast-config.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ general:
2323
# Scanner configurations
2424
scanners:
2525
zap:
26+
# Import URLs from file for comprehensive API scanning
27+
importUrlsFromFile:
28+
fileName: "rapidast-urls.txt"
29+
2630
# Passive scanner configuration
2731
passiveScan:
2832
# Disable rules that may cause false positives for our use case
@@ -33,16 +37,6 @@ scanners:
3337
# Use minimal policy suitable for APIs
3438
policy: "API-scan-minimal"
3539

36-
# Spider configuration
37-
spider:
38-
url: "http://localhost:3000"
39-
maxDuration: 10 # minutes
40-
41-
# AJAX spider for dynamic content
42-
spiderAjax:
43-
url: "http://localhost:3000"
44-
maxDuration: 5 # minutes
45-
4640
# Miscellaneous options
4741
miscOptions:
4842
# Add additional ZAP add-ons if needed

scripts/generate-rapidast-urls.cjs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Generate RapiDAST seed URLs from MCP server configuration
5+
*
6+
* This script reads the aap-mcp.yaml configuration and generates
7+
* a list of all API endpoints that should be scanned by RapiDAST.
8+
*/
9+
10+
const fs = require('fs');
11+
const path = require('path');
12+
const yaml = require('yaml');
13+
14+
const CONFIG_FILE = process.env.CONFIG_FILE || 'aap-mcp.yaml';
15+
const OUTPUT_FILE = process.env.OUTPUT_FILE || 'rapidast-urls.txt';
16+
const BASE_URL = process.env.BASE_URL || 'http://localhost:3000';
17+
18+
function generateUrls() {
19+
// Read the configuration file
20+
let config;
21+
try {
22+
const configPath = path.join(process.cwd(), CONFIG_FILE);
23+
const configContent = fs.readFileSync(configPath, 'utf8');
24+
config = yaml.parse(configContent);
25+
} catch (error) {
26+
console.error(`Error reading config file ${CONFIG_FILE}:`, error.message);
27+
process.exit(1);
28+
}
29+
30+
const urls = new Set();
31+
32+
// Production-only endpoints
33+
// Health check endpoint (always available in production)
34+
urls.add(`${BASE_URL}/api/v1/health`);
35+
36+
// Main MCP endpoint (primary production endpoint)
37+
urls.add(`${BASE_URL}/mcp`);
38+
39+
// Category-based MCP endpoints (production API routes)
40+
if (config.categories) {
41+
Object.keys(config.categories).forEach(category => {
42+
if (config.categories[category].enabled !== false) {
43+
// Both MCP endpoint formats for each category
44+
urls.add(`${BASE_URL}/${category}/mcp`);
45+
urls.add(`${BASE_URL}/mcp/${category}`);
46+
}
47+
});
48+
}
49+
50+
// Note: Excluding informational/UI endpoints that are not available in production:
51+
// - /tools, /tools/:name
52+
// - /services, /services/:name
53+
// - /category, /category/:name
54+
// - /endpoints
55+
// These are development/documentation endpoints only
56+
57+
return Array.from(urls).sort();
58+
}
59+
60+
// Generate URLs
61+
const urls = generateUrls();
62+
63+
// Write to file
64+
const outputPath = path.join(process.cwd(), OUTPUT_FILE);
65+
fs.writeFileSync(outputPath, urls.join('\n') + '\n', 'utf8');
66+
67+
console.log(`Generated ${urls.length} URLs for RapiDAST scanning`);
68+
console.log(`URLs written to: ${outputPath}`);
69+
console.log('\nSample URLs:');
70+
urls.slice(0, 10).forEach(url => console.log(` ${url}`));
71+
if (urls.length > 10) {
72+
console.log(` ... and ${urls.length - 10} more`);
73+
}

0 commit comments

Comments
 (0)