Fix Mode (Solution Comparison)
The --fix mode generates git-style unified diffs comparing the vulnerable code against each of the four solution options.
Usage
node src/index.js --fix --url "..."
What it collects
For each of the four solution options (SOLUTION_1 through SOLUTION_4):
- Clicks the "VULNERABLE_CODE" comparison base button
- Clicks each solution button in sequence
- Parses the side-by-side diff table into unified diff format
- Collects diffs for each file tab
Diff generation
The tool parses the SCW comparison table (which has columns for old line number, old content, new line number, and new content) and generates standard unified diff hunks:
- Context lines (unchanged) are prefixed with a space
- Removed lines are prefixed with
- - Added lines are prefixed with
+ - Hunks include
@@headers with line number ranges - Only changed regions with 4 lines of context are included
Output format
# Challenge Title
## Solution 1
### app.js
\`\`\`diff
@@ -10,6 +10,8 @@
const express = require('express');
const app = express();
-app.use(bodyParser.urlencoded({ extended: true }));
+app.use(bodyParser.urlencoded({ extended: false }));
+app.use(helmet());
app.listen(3000);
\`\`\`
## Solution 2
### app.js
\`\`\`diff
@@ -10,6 +10,7 @@
...
\`\`\`
When to use
Use --fix when the Secure Code Warrior challenge presents multiple fix options and you want to compare them side-by-side in a structured diff format, ideal for AI-assisted code review.