agent-security-scanner-mcp 2.0.6 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +97 -1
  2. package/index.js +126 -2
  3. package/package.json +5 -2
package/README.md CHANGED
@@ -65,6 +65,13 @@ The scanner works without tree-sitter using regex-based detection, but AST analy
65
65
 
66
66
  ---
67
67
 
68
+ ## What's New in v2.0.7
69
+
70
+ - **SARIF output format** - `scan_security` now supports `output_format: 'sarif'` for GitHub/GitLab Security tab integration
71
+ - **GitHub Code Scanning** - Upload results directly to GitHub Advanced Security
72
+ - **GitLab SAST** - Compatible with GitLab's security dashboard
73
+ - **Full SARIF 2.1.0 compliance** - Includes rules, locations, fix suggestions, CWE/OWASP metadata
74
+
68
75
  ## What's New in v2.0.6
69
76
 
70
77
  - **fix_security reliability overhaul** - Fixes now validated before applying to prevent malformed code output
@@ -368,6 +375,7 @@ Scan a file for security vulnerabilities and return issues with suggested fixes.
368
375
  ```
369
376
  Parameters:
370
377
  file_path (string): Absolute path to the file to scan
378
+ output_format (string, optional): 'json' (default) or 'sarif' for GitHub/GitLab integration
371
379
 
372
380
  Returns:
373
381
  - List of security issues
@@ -377,7 +385,7 @@ Returns:
377
385
  - Suggested fixes
378
386
  ```
379
387
 
380
- **Example output:**
388
+ **Example output (JSON - default):**
381
389
  ```json
382
390
  {
383
391
  "file": "/path/to/file.js",
@@ -403,6 +411,36 @@ Returns:
403
411
  }
404
412
  ```
405
413
 
414
+ **Example output (SARIF - for GitHub/GitLab):**
415
+ ```json
416
+ {
417
+ "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
418
+ "version": "2.1.0",
419
+ "runs": [{
420
+ "tool": {
421
+ "driver": {
422
+ "name": "agent-security-scanner-mcp",
423
+ "version": "2.0.7",
424
+ "rules": [...]
425
+ }
426
+ },
427
+ "results": [
428
+ {
429
+ "ruleId": "sql-injection",
430
+ "level": "error",
431
+ "message": { "text": "SQL Injection detected" },
432
+ "locations": [{
433
+ "physicalLocation": {
434
+ "artifactLocation": { "uri": "file.js" },
435
+ "region": { "startLine": 15 }
436
+ }
437
+ }]
438
+ }
439
+ ]
440
+ }]
441
+ }
442
+ ```
443
+
406
444
  ### `fix_security`
407
445
 
408
446
  Automatically fix all security issues in a file.
@@ -640,6 +678,64 @@ Package lists are sourced from [garak-llm](https://huggingface.co/garak-llm) Hug
640
678
 
641
679
  ---
642
680
 
681
+ ## CI/CD Integration (SARIF)
682
+
683
+ Upload scan results to GitHub Security tab or GitLab Security Dashboard using SARIF format.
684
+
685
+ ### GitHub Actions Example
686
+
687
+ ```yaml
688
+ name: Security Scan
689
+ on: [push, pull_request]
690
+
691
+ jobs:
692
+ security:
693
+ runs-on: ubuntu-latest
694
+ steps:
695
+ - uses: actions/checkout@v4
696
+
697
+ - name: Setup Node.js
698
+ uses: actions/setup-node@v4
699
+ with:
700
+ node-version: '20'
701
+
702
+ - name: Run Security Scanner
703
+ run: |
704
+ npx agent-security-scanner-mcp scan src/ --format sarif --output results.sarif
705
+
706
+ - name: Upload SARIF to GitHub
707
+ uses: github/codeql-action/upload-sarif@v3
708
+ with:
709
+ sarif_file: results.sarif
710
+ ```
711
+
712
+ ### GitLab CI Example
713
+
714
+ ```yaml
715
+ security_scan:
716
+ stage: test
717
+ script:
718
+ - npx agent-security-scanner-mcp scan src/ --format sarif --output gl-sast-report.json
719
+ artifacts:
720
+ reports:
721
+ sast: gl-sast-report.json
722
+ ```
723
+
724
+ ### Programmatic Usage
725
+
726
+ ```javascript
727
+ // Use output_format: 'sarif' parameter
728
+ const result = await client.callTool({
729
+ name: 'scan_security',
730
+ arguments: {
731
+ file_path: '/path/to/file.js',
732
+ output_format: 'sarif' // Returns SARIF 2.1.0 format
733
+ }
734
+ });
735
+ ```
736
+
737
+ ---
738
+
643
739
  ## Security Rules (359 total)
644
740
 
645
741
  ### By Language
package/index.js CHANGED
@@ -949,14 +949,126 @@ export function createSandboxServer() {
949
949
  return server;
950
950
  }
951
951
 
952
+ // SARIF (Static Analysis Results Interchange Format) conversion
953
+ // Spec: https://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html
954
+ function convertToSarif(filePath, language, issues) {
955
+ const severityToLevel = {
956
+ 'ERROR': 'error',
957
+ 'WARNING': 'warning',
958
+ 'INFO': 'note',
959
+ 'HINT': 'note'
960
+ };
961
+
962
+ // Build rules from unique rule IDs
963
+ const rulesMap = new Map();
964
+ issues.forEach(issue => {
965
+ if (!rulesMap.has(issue.ruleId)) {
966
+ rulesMap.set(issue.ruleId, {
967
+ id: issue.ruleId,
968
+ name: issue.ruleId.split('.').pop().replace(/-/g, ' ').replace(/\b\w/g, c => c.toUpperCase()),
969
+ shortDescription: {
970
+ text: issue.message.replace(/^\[.*?\]\s*/, '') // Remove [RuleName] prefix
971
+ },
972
+ defaultConfiguration: {
973
+ level: severityToLevel[issue.severity] || 'warning'
974
+ },
975
+ properties: {
976
+ tags: ['security'],
977
+ ...(issue.metadata?.cwe && { 'security-severity': '7.0' }),
978
+ },
979
+ helpUri: issue.metadata?.references?.[0] || `https://cwe.mitre.org/data/definitions/${issue.metadata?.cwe?.replace('CWE-', '')}.html`
980
+ });
981
+ }
982
+ });
983
+
984
+ // Build results
985
+ const results = issues.map(issue => ({
986
+ ruleId: issue.ruleId,
987
+ level: severityToLevel[issue.severity] || 'warning',
988
+ message: {
989
+ text: issue.message
990
+ },
991
+ locations: [{
992
+ physicalLocation: {
993
+ artifactLocation: {
994
+ uri: filePath,
995
+ uriBaseId: '%SRCROOT%'
996
+ },
997
+ region: {
998
+ startLine: (issue.line || 0) + 1, // SARIF uses 1-indexed lines
999
+ startColumn: (issue.column || 0) + 1,
1000
+ endLine: (issue.endLine || issue.line || 0) + 1,
1001
+ endColumn: (issue.endColumn || issue.column || 0) + 1,
1002
+ snippet: issue.line_content ? { text: issue.line_content } : undefined
1003
+ }
1004
+ }
1005
+ }],
1006
+ ...(issue.suggested_fix?.fixed && {
1007
+ fixes: [{
1008
+ description: {
1009
+ text: issue.suggested_fix.description
1010
+ },
1011
+ artifactChanges: [{
1012
+ artifactLocation: {
1013
+ uri: filePath
1014
+ },
1015
+ replacements: [{
1016
+ deletedRegion: {
1017
+ startLine: (issue.line || 0) + 1,
1018
+ startColumn: 1,
1019
+ endLine: (issue.line || 0) + 1,
1020
+ endColumn: (issue.suggested_fix.original?.length || 0) + 1
1021
+ },
1022
+ insertedContent: {
1023
+ text: issue.suggested_fix.fixed
1024
+ }
1025
+ }]
1026
+ }]
1027
+ }]
1028
+ }),
1029
+ properties: {
1030
+ ...(issue.metadata?.cwe && { cwe: issue.metadata.cwe }),
1031
+ ...(issue.metadata?.owasp && { owasp: issue.metadata.owasp })
1032
+ }
1033
+ }));
1034
+
1035
+ return {
1036
+ $schema: 'https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json',
1037
+ version: '2.1.0',
1038
+ runs: [{
1039
+ tool: {
1040
+ driver: {
1041
+ name: 'agent-security-scanner-mcp',
1042
+ version: '2.0.7',
1043
+ informationUri: 'https://github.com/sinewaveai/agent-security-scanner-mcp',
1044
+ rules: Array.from(rulesMap.values())
1045
+ }
1046
+ },
1047
+ results,
1048
+ invocations: [{
1049
+ executionSuccessful: true,
1050
+ endTimeUtc: new Date().toISOString()
1051
+ }],
1052
+ artifacts: [{
1053
+ location: {
1054
+ uri: filePath,
1055
+ uriBaseId: '%SRCROOT%'
1056
+ },
1057
+ sourceLanguage: language
1058
+ }]
1059
+ }]
1060
+ };
1061
+ }
1062
+
952
1063
  // Register scan_security tool
953
1064
  server.tool(
954
1065
  "scan_security",
955
1066
  "Scan a file for security vulnerabilities and return issues with suggested fixes",
956
1067
  {
957
- file_path: z.string().describe("Path to the file to scan")
1068
+ file_path: z.string().describe("Path to the file to scan"),
1069
+ output_format: z.enum(['json', 'sarif']).optional().describe("Output format: 'json' (default) or 'sarif' for GitHub/GitLab integration")
958
1070
  },
959
- async ({ file_path }) => {
1071
+ async ({ file_path, output_format = 'json' }) => {
960
1072
  if (!existsSync(file_path)) {
961
1073
  return {
962
1074
  content: [{ type: "text", text: JSON.stringify({ error: "File not found" }) }]
@@ -987,6 +1099,18 @@ server.tool(
987
1099
  };
988
1100
  });
989
1101
 
1102
+ // Return SARIF format if requested (for GitHub/GitLab integration)
1103
+ if (output_format === 'sarif') {
1104
+ const sarif = convertToSarif(file_path, language, enhancedIssues);
1105
+ return {
1106
+ content: [{
1107
+ type: "text",
1108
+ text: JSON.stringify(sarif, null, 2)
1109
+ }]
1110
+ };
1111
+ }
1112
+
1113
+ // Default JSON format
990
1114
  return {
991
1115
  content: [{
992
1116
  type: "text",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-security-scanner-mcp",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "mcpName": "io.github.sinewaveai/agent-security-scanner-mcp",
5
5
  "description": "Security scanner MCP server for AI coding agents. Prompt injection firewall, package hallucination detection (4.3M+ packages), 359 vulnerability rules with auto-fix. For Claude Code, Cursor, Windsurf, Cline.",
6
6
  "main": "index.js",
@@ -52,7 +52,10 @@
52
52
  "zed",
53
53
  "prompt-firewall",
54
54
  "auto-fix",
55
- "hallucination"
55
+ "hallucination",
56
+ "sarif",
57
+ "github-code-scanning",
58
+ "gitlab-sast"
56
59
  ],
57
60
  "author": "Sinewave AI <divya@sinewave.ai>",
58
61
  "license": "MIT",