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 @@
|
|
|
1
|
+
{"version":3,"file":"credentials-crypto.js","sourceRoot":"","sources":["../../../../../../../../src/lib/analyzers/go/security-checks/credentials-crypto.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAiBH,8DA+SC;AA7TD,sEAA6E;AAE7E;;;;;;;;;;;GAWG;AACH,SAAgB,yBAAyB,CAAC,KAAe;IACvD,MAAM,eAAe,GAA4B,EAAE,CAAC;IACpD,IAAI,kBAAkB,GAAG,KAAK,CAAC;IAE/B,6DAA6D;IAC7D,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,mBAAmB,GAAG,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/D,MAAM,iBAAiB,GAAG,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAE3D,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC5B,MAAM,UAAU,GAAG,KAAK,GAAG,CAAC,CAAC;QAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAE5B,wCAAwC;QACxC,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,kBAAkB,GAAG,IAAI,CAAC;QAC5B,CAAC;QACD,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,kBAAkB,GAAG,KAAK,CAAC;YAC3B,OAAO;QACT,CAAC;QAED,gCAAgC;QAChC,IAAI,CAAC,OAAO,IAAI,kBAAkB,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wH;wBAC1H,cAAc,EAAE,gFAAgF;wBAChG,eAAe,EAAE;4BACf,gCAAgC;4BAChC,mBAAmB;4BACnB,uBAAuB;4BACvB,8BAA8B;yBAC/B;qBACF;iBACF,CAAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go Deserialization Security Checks
|
|
3
|
+
* OWASP A08:2025 - Software and Data Integrity Failures
|
|
4
|
+
*
|
|
5
|
+
* Detects unsafe deserialization vulnerabilities in Go code, particularly
|
|
6
|
+
* with gob encoding and JSON unmarshaling from untrusted sources.
|
|
7
|
+
*/
|
|
8
|
+
import { SecurityVulnerability } from '../../types';
|
|
9
|
+
/**
|
|
10
|
+
* Checks for unsafe deserialization practices
|
|
11
|
+
*
|
|
12
|
+
* Covers:
|
|
13
|
+
* - Check #1: Unsafe gob/JSON deserialization from untrusted sources (HIGH)
|
|
14
|
+
*
|
|
15
|
+
* @param lines - Array of code lines
|
|
16
|
+
* @returns Array of security vulnerabilities found
|
|
17
|
+
*/
|
|
18
|
+
export declare function checkDeserialization(lines: string[]): SecurityVulnerability[];
|
|
19
|
+
//# sourceMappingURL=deserialization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deserialization.d.ts","sourceRoot":"","sources":["../../../../../../../../src/lib/analyzers/go/security-checks/deserialization.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGpD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,qBAAqB,EAAE,CAsO7E"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Go Deserialization Security Checks
|
|
4
|
+
* OWASP A08:2025 - Software and Data Integrity Failures
|
|
5
|
+
*
|
|
6
|
+
* Detects unsafe deserialization vulnerabilities in Go code, particularly
|
|
7
|
+
* with gob encoding and JSON unmarshaling from untrusted sources.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.checkDeserialization = checkDeserialization;
|
|
11
|
+
const createVulnerability_1 = require("../utils/createVulnerability");
|
|
12
|
+
/**
|
|
13
|
+
* Checks for unsafe deserialization practices
|
|
14
|
+
*
|
|
15
|
+
* Covers:
|
|
16
|
+
* - Check #1: Unsafe gob/JSON deserialization from untrusted sources (HIGH)
|
|
17
|
+
*
|
|
18
|
+
* @param lines - Array of code lines
|
|
19
|
+
* @returns Array of security vulnerabilities found
|
|
20
|
+
*/
|
|
21
|
+
function checkDeserialization(lines) {
|
|
22
|
+
const vulnerabilities = [];
|
|
23
|
+
let inMultiLineComment = false;
|
|
24
|
+
// First pass: Check for deserialization imports
|
|
25
|
+
const fileContent = lines.join('\n');
|
|
26
|
+
const hasGobImport = /encoding\/gob|gob\./i.test(fileContent);
|
|
27
|
+
const hasJSONImport = /encoding\/json|json\./i.test(fileContent);
|
|
28
|
+
// Track user input sources (HTTP requests, external files, network)
|
|
29
|
+
const userInputVars = new Set();
|
|
30
|
+
// First pass: Identify user input sources
|
|
31
|
+
lines.forEach((line, index) => {
|
|
32
|
+
const trimmed = line.trim();
|
|
33
|
+
// HTTP request body
|
|
34
|
+
const bodyMatch = trimmed.match(/(\w+)\s*(?::=|=)\s*(?:r\.Body|req\.Body|request\.Body)/i);
|
|
35
|
+
if (bodyMatch) {
|
|
36
|
+
userInputVars.add(bodyMatch[1]);
|
|
37
|
+
}
|
|
38
|
+
// HTTP request parameters
|
|
39
|
+
const paramMatch = trimmed.match(/(\w+)\s*(?::=|=)\s*(?:r\.(?:URL\.Query\(\)|FormValue|PostFormValue|Header\.Get)|chi\.URLParam|mux\.Vars|c\.(?:Query|Param))/i);
|
|
40
|
+
if (paramMatch) {
|
|
41
|
+
userInputVars.add(paramMatch[1]);
|
|
42
|
+
}
|
|
43
|
+
// File reading
|
|
44
|
+
const fileMatch = trimmed.match(/(\w+)\s*(?::=|=)\s*(?:os\.Open|ioutil\.ReadFile|os\.ReadFile)\s*\(/i);
|
|
45
|
+
if (fileMatch) {
|
|
46
|
+
userInputVars.add(fileMatch[1]);
|
|
47
|
+
}
|
|
48
|
+
// Network connections (assignments and function parameters)
|
|
49
|
+
const netMatch = trimmed.match(/(\w+)\s*(?::=|=)\s*(?:net\.Dial|http\.Get|http\.Post)\s*\(/i);
|
|
50
|
+
if (netMatch) {
|
|
51
|
+
userInputVars.add(netMatch[1]);
|
|
52
|
+
}
|
|
53
|
+
// Function parameters with net.Conn, io.Reader types (external input)
|
|
54
|
+
const paramTypeMatch = trimmed.match(/func\s+\w+\s*\([^)]*?(\w+)\s+(?:net\.Conn|io\.Reader)/i);
|
|
55
|
+
if (paramTypeMatch) {
|
|
56
|
+
userInputVars.add(paramTypeMatch[1]);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
// Second pass: Check for unsafe deserialization
|
|
60
|
+
lines.forEach((line, index) => {
|
|
61
|
+
const lineNumber = index + 1;
|
|
62
|
+
const trimmed = line.trim();
|
|
63
|
+
// Track multi-line comments (/* ... */)
|
|
64
|
+
if (trimmed.includes('/*')) {
|
|
65
|
+
inMultiLineComment = true;
|
|
66
|
+
}
|
|
67
|
+
if (trimmed.includes('*/')) {
|
|
68
|
+
inMultiLineComment = false;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// Skip comments and empty lines
|
|
72
|
+
if (!trimmed || inMultiLineComment || trimmed.startsWith('//')) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// =============================================================================
|
|
76
|
+
// Check #1: Unsafe Deserialization from Untrusted Sources
|
|
77
|
+
// =============================================================================
|
|
78
|
+
// CVSS 8.0 - HIGH
|
|
79
|
+
// Detects gob.Decode or json.Unmarshal from user-controlled input
|
|
80
|
+
// Check for gob.Decode
|
|
81
|
+
if (hasGobImport && /gob\.(?:NewDecoder|Decode)/i.test(trimmed)) {
|
|
82
|
+
// Look for user input in surrounding ±10 lines
|
|
83
|
+
let hasUserInput = false;
|
|
84
|
+
const startLine = Math.max(0, index - 10);
|
|
85
|
+
const endLine = Math.min(lines.length, index + 10);
|
|
86
|
+
for (let i = startLine; i < endLine; i++) {
|
|
87
|
+
const contextLine = lines[i].trim();
|
|
88
|
+
// Check if any tracked user input variable is used
|
|
89
|
+
for (const userVar of userInputVars) {
|
|
90
|
+
if (new RegExp(`\\b${userVar}\\b`, 'i').test(contextLine)) {
|
|
91
|
+
hasUserInput = true;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Direct patterns indicating external input
|
|
96
|
+
if (/r\.Body|req\.Body|request\.Body|os\.Open|net\.Dial|http\.Get|http\.Post/i.test(contextLine)) {
|
|
97
|
+
hasUserInput = true;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (hasUserInput)
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
// Also check for validation/signature verification
|
|
104
|
+
let hasValidation = false;
|
|
105
|
+
for (let i = startLine; i < endLine; i++) {
|
|
106
|
+
const contextLine = lines[i].trim();
|
|
107
|
+
if (/hmac|verify|signature|authenticate|crypto\.subtle|jwt\.Parse/i.test(contextLine)) {
|
|
108
|
+
hasValidation = true;
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (hasUserInput && !hasValidation) {
|
|
113
|
+
vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
|
|
114
|
+
category: 'go-unsafe-deserialization',
|
|
115
|
+
severity: 'high',
|
|
116
|
+
confidence: 'high',
|
|
117
|
+
message: 'Unsafe deserialization: gob.Decode used on untrusted input without validation',
|
|
118
|
+
line: lineNumber,
|
|
119
|
+
suggestion: 'Validate and sanitize input before deserialization, or use safer formats like JSON with schema validation',
|
|
120
|
+
owasp: 'A08:2025 - Software and Data Integrity Failures',
|
|
121
|
+
cwe: 'CWE-502',
|
|
122
|
+
pciDss: 'PCI DSS 6.5.8',
|
|
123
|
+
remediation: {
|
|
124
|
+
explanation: 'gob encoding can execute arbitrary code during deserialization if the input is malicious. Always validate input, use HMAC signatures, or prefer safer formats like JSON with strict schema validation.',
|
|
125
|
+
before: `// UNSAFE\ndecoder := gob.NewDecoder(r.Body)\nvar data MyStruct\ndecoder.Decode(&data) // Can execute malicious code!`,
|
|
126
|
+
after: `// SAFE - Validate with HMAC\nmac := hmac.New(sha256.New, secretKey)\nif !hmac.Equal(receivedMAC, mac.Sum(nil)) {\n return errors.New("invalid signature")\n}\ndecoder := gob.NewDecoder(validatedReader)\nvar data MyStruct\ndecoder.Decode(&data)`
|
|
127
|
+
},
|
|
128
|
+
attackVector: {
|
|
129
|
+
description: 'gob deserialization can trigger arbitrary code execution through specially crafted payloads. Attackers can exploit this to execute commands, modify memory, or bypass security controls.',
|
|
130
|
+
exploitExample: `// Attacker sends malicious gob payload:\nPOST /api/process\nContent-Type: application/gob\n\n<malicious gob data with embedded code>\n\n// Server blindly deserializes:\ngob.NewDecoder(r.Body).Decode(&data)\n// Attacker gains code execution!`,
|
|
131
|
+
realWorldImpact: [
|
|
132
|
+
'Remote code execution (RCE)',
|
|
133
|
+
'Complete server compromise',
|
|
134
|
+
'Data exfiltration and modification',
|
|
135
|
+
'Privilege escalation',
|
|
136
|
+
'Bypassing authentication and authorization'
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// Check for json.Unmarshal from untrusted sources
|
|
143
|
+
if (hasJSONImport && /json\.(?:Unmarshal|NewDecoder)\s*\(/i.test(trimmed)) {
|
|
144
|
+
// Look for user input in surrounding ±10 lines
|
|
145
|
+
let hasUserInput = false;
|
|
146
|
+
let hasInterfaceType = false;
|
|
147
|
+
const startLine = Math.max(0, index - 10);
|
|
148
|
+
const endLine = Math.min(lines.length, index + 10);
|
|
149
|
+
for (let i = startLine; i < endLine; i++) {
|
|
150
|
+
const contextLine = lines[i].trim();
|
|
151
|
+
// Check for user input sources
|
|
152
|
+
for (const userVar of userInputVars) {
|
|
153
|
+
if (new RegExp(`\\b${userVar}\\b`, 'i').test(contextLine)) {
|
|
154
|
+
hasUserInput = true;
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (/r\.Body|req\.Body|request\.Body|os\.Open|net\.Dial|http\.Get|http\.Post/i.test(contextLine)) {
|
|
159
|
+
hasUserInput = true;
|
|
160
|
+
}
|
|
161
|
+
// Check if unmarshaling into interface{} or map[string]interface{}
|
|
162
|
+
if (/interface\s*\{\}|map\s*\[\s*string\s*\]\s*interface/i.test(contextLine)) {
|
|
163
|
+
hasInterfaceType = true;
|
|
164
|
+
}
|
|
165
|
+
if (hasUserInput && hasInterfaceType)
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
// Check for schema validation
|
|
169
|
+
let hasSchemaValidation = false;
|
|
170
|
+
for (let i = startLine; i < endLine; i++) {
|
|
171
|
+
const contextLine = lines[i].trim();
|
|
172
|
+
if (/validate|schema|sanitize|whitelist/i.test(contextLine)) {
|
|
173
|
+
hasSchemaValidation = true;
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (hasUserInput && hasInterfaceType && !hasSchemaValidation) {
|
|
178
|
+
vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
|
|
179
|
+
category: 'go-unsafe-deserialization',
|
|
180
|
+
severity: 'high',
|
|
181
|
+
confidence: 'medium',
|
|
182
|
+
message: 'Unsafe JSON deserialization: Unmarshaling untrusted input into interface{} without validation',
|
|
183
|
+
line: lineNumber,
|
|
184
|
+
suggestion: 'Use strongly-typed structs and validate input against a schema before unmarshaling',
|
|
185
|
+
owasp: 'A08:2025 - Software and Data Integrity Failures',
|
|
186
|
+
cwe: 'CWE-502',
|
|
187
|
+
pciDss: 'PCI DSS 6.5.8',
|
|
188
|
+
remediation: {
|
|
189
|
+
explanation: 'Unmarshaling JSON into interface{} or map[string]interface{} from untrusted sources allows attackers to inject unexpected data types and structures. Use strongly-typed structs with validation.',
|
|
190
|
+
before: `// UNSAFE\nvar data interface{}\njson.NewDecoder(r.Body).Decode(&data)\n// Attacker can inject any JSON structure`,
|
|
191
|
+
after: `// SAFE\ntype UserRequest struct {\n Name string \`json:"name" validate:"required,max=100"\`\n Email string \`json:"email" validate:"required,email"\`\n}\nvar data UserRequest\nif err := json.NewDecoder(r.Body).Decode(&data); err != nil {\n return err\n}\nif err := validate.Struct(data); err != nil {\n return err\n}`
|
|
192
|
+
},
|
|
193
|
+
attackVector: {
|
|
194
|
+
description: 'Deserializing JSON into interface{} allows attackers to inject unexpected data types, nested objects, or large payloads causing DoS, logic errors, or security bypasses.',
|
|
195
|
+
exploitExample: `// Expected: {"userId": 123}\n// Attacker sends: {"userId": {"$ne": 0}}\n// Code: var data interface{}\njson.Unmarshal(input, &data)\n// NoSQL injection or logic bypass!`,
|
|
196
|
+
realWorldImpact: [
|
|
197
|
+
'NoSQL injection via type confusion',
|
|
198
|
+
'Denial of Service (memory exhaustion)',
|
|
199
|
+
'Logic errors and security bypasses',
|
|
200
|
+
'Mass assignment vulnerabilities',
|
|
201
|
+
'Data corruption'
|
|
202
|
+
]
|
|
203
|
+
}
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
return vulnerabilities;
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=deserialization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deserialization.js","sourceRoot":"","sources":["../../../../../../../../src/lib/analyzers/go/security-checks/deserialization.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAcH,oDAsOC;AAjPD,sEAA6E;AAE7E;;;;;;;;GAQG;AACH,SAAgB,o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AAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go Error Handling Security Checks
|
|
3
|
+
* OWASP A09:2025 - Security Logging and Monitoring Failures
|
|
4
|
+
*
|
|
5
|
+
* Detects improper error handling and insufficient security logging in Go code.
|
|
6
|
+
*/
|
|
7
|
+
import { SecurityVulnerability } from '../../types';
|
|
8
|
+
/**
|
|
9
|
+
* Checks for error handling and logging issues
|
|
10
|
+
*
|
|
11
|
+
* Covers:
|
|
12
|
+
* - Check #1: Ignored errors (blank identifier _) (LOW)
|
|
13
|
+
* - Check #2: Missing security event logging (MEDIUM)
|
|
14
|
+
*
|
|
15
|
+
* @param lines - Array of code lines
|
|
16
|
+
* @returns Array of security vulnerabilities found
|
|
17
|
+
*/
|
|
18
|
+
export declare function checkErrorHandling(lines: string[]): SecurityVulnerability[];
|
|
19
|
+
//# sourceMappingURL=error-handling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handling.d.ts","sourceRoot":"","sources":["../../../../../../../../src/lib/analyzers/go/security-checks/error-handling.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGpD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,qBAAqB,EAAE,CA6M3E"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Go Error Handling Security Checks
|
|
4
|
+
* OWASP A09:2025 - Security Logging and Monitoring Failures
|
|
5
|
+
*
|
|
6
|
+
* Detects improper error handling and insufficient security logging in Go code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.checkErrorHandling = checkErrorHandling;
|
|
10
|
+
const createVulnerability_1 = require("../utils/createVulnerability");
|
|
11
|
+
/**
|
|
12
|
+
* Checks for error handling and logging issues
|
|
13
|
+
*
|
|
14
|
+
* Covers:
|
|
15
|
+
* - Check #1: Ignored errors (blank identifier _) (LOW)
|
|
16
|
+
* - Check #2: Missing security event logging (MEDIUM)
|
|
17
|
+
*
|
|
18
|
+
* @param lines - Array of code lines
|
|
19
|
+
* @returns Array of security vulnerabilities found
|
|
20
|
+
*/
|
|
21
|
+
function checkErrorHandling(lines) {
|
|
22
|
+
const vulnerabilities = [];
|
|
23
|
+
let inMultiLineComment = false;
|
|
24
|
+
const fileContent = lines.join('\n');
|
|
25
|
+
const hasLoggingImport = /log\.|logrus\.|zap\.|zerolog\./i.test(fileContent);
|
|
26
|
+
lines.forEach((line, index) => {
|
|
27
|
+
const lineNumber = index + 1;
|
|
28
|
+
const trimmed = line.trim();
|
|
29
|
+
// Track multi-line comments (/* ... */)
|
|
30
|
+
if (trimmed.includes('/*')) {
|
|
31
|
+
inMultiLineComment = true;
|
|
32
|
+
}
|
|
33
|
+
if (trimmed.includes('*/')) {
|
|
34
|
+
inMultiLineComment = false;
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// Skip comments and empty lines
|
|
38
|
+
if (!trimmed || inMultiLineComment || trimmed.startsWith('//')) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
// =============================================================================
|
|
42
|
+
// Check #1: Ignored Errors (Blank Identifier _)
|
|
43
|
+
// =============================================================================
|
|
44
|
+
// CVSS 3.1 - LOW
|
|
45
|
+
// Detects errors being explicitly ignored with _
|
|
46
|
+
// Pattern:
|
|
47
|
+
// - _, anything := or anything, _ := (multi-value assignment with blank identifier)
|
|
48
|
+
// - _ = someFunc() (single-value assignment)
|
|
49
|
+
// BUT exclude inline error checks: if _, err := ...; err != nil
|
|
50
|
+
const hasIgnoredError = /\w+\s*,\s*_\s*:=|_\s*,\s*\w+\s*:=|_\s*=\s*[\w.]+\s*\(/i.test(trimmed);
|
|
51
|
+
// Inline error check pattern matches both: if _, err := ...; err != and if result, _ := ...; result !=
|
|
52
|
+
const isInlineErrorCheck = /if\s+[_\w]+\s*,\s*[_\w]+\s*:=.*;\s*\w+\s*!=/i.test(trimmed);
|
|
53
|
+
if (hasIgnoredError && !isInlineErrorCheck) {
|
|
54
|
+
// Check if this is a security-critical operation
|
|
55
|
+
const isSecurityCritical = /db\.|sql\.|crypto|tls\.|rand\.|auth|password|token|session|encrypt|decrypt|sign|verify|validate|jwt|bcrypt|hash/i.test(trimmed);
|
|
56
|
+
if (isSecurityCritical) {
|
|
57
|
+
vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
|
|
58
|
+
category: 'go-ignored-error',
|
|
59
|
+
severity: 'low',
|
|
60
|
+
confidence: 'medium',
|
|
61
|
+
message: 'Error ignored in security-critical operation',
|
|
62
|
+
line: lineNumber,
|
|
63
|
+
suggestion: 'Always check and handle errors from security-critical operations',
|
|
64
|
+
owasp: 'A09:2025 - Security Logging and Monitoring Failures',
|
|
65
|
+
cwe: 'CWE-391',
|
|
66
|
+
pciDss: 'PCI DSS 10.1',
|
|
67
|
+
remediation: {
|
|
68
|
+
explanation: 'Ignoring errors from security-critical operations can lead to silent failures. Database errors, cryptographic failures, and authentication issues must be detected and handled.',
|
|
69
|
+
before: `_, err := db.Exec("UPDATE users SET password = ?", hash)\n// Silent failure - password not updated!`,
|
|
70
|
+
after: `result, err := db.Exec("UPDATE users SET password = ?", hash)\nif err != nil {\n log.Printf("Password update failed: %v", err)\n return err\n}`
|
|
71
|
+
},
|
|
72
|
+
attackVector: {
|
|
73
|
+
description: 'Silent failures in security operations can leave the system in an insecure state. For example, ignored encryption errors might result in unencrypted data storage.',
|
|
74
|
+
exploitExample: `// Encryption error ignored:\nencrypted, _ := encrypt(sensitiveData)\ndb.Save(encrypted) // Actually saved plaintext due to error!`,
|
|
75
|
+
realWorldImpact: [
|
|
76
|
+
'Silent security failures go undetected',
|
|
77
|
+
'Data stored unencrypted despite encryption attempts',
|
|
78
|
+
'Authentication bypasses due to ignored validation errors',
|
|
79
|
+
'Audit trail gaps from unreported failures',
|
|
80
|
+
'Difficult troubleshooting and incident response'
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// =============================================================================
|
|
87
|
+
// Check #2: Missing Security Event Logging
|
|
88
|
+
// =============================================================================
|
|
89
|
+
// CVSS 4.0 - MEDIUM
|
|
90
|
+
// Detects security-relevant operations without logging
|
|
91
|
+
// Check for authentication/authorization without logging
|
|
92
|
+
const isAuthOperation = /Login|Authenticate|Authorize|SignIn|SignOut|ChangePassword|ResetPassword|Grant|Revoke/i.test(trimmed);
|
|
93
|
+
const isFunctionDeclaration = /func\s+(\w+)/i.test(trimmed);
|
|
94
|
+
if (isAuthOperation && isFunctionDeclaration) {
|
|
95
|
+
const funcMatch = trimmed.match(/func\s+(\w+)/i);
|
|
96
|
+
if (funcMatch) {
|
|
97
|
+
const funcName = funcMatch[1];
|
|
98
|
+
// Look ahead in function body (next 40 lines) for logging
|
|
99
|
+
let hasLogging = false;
|
|
100
|
+
for (let i = index; i < Math.min(index + 40, lines.length); i++) {
|
|
101
|
+
const bodyLine = lines[i].trim();
|
|
102
|
+
// Stop at next function
|
|
103
|
+
if (i > index && /^func\s+\w+/.test(bodyLine)) {
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
// Check for logging statements
|
|
107
|
+
if (/log\.|logrus\.|zap\.|zerolog\.|slog\./i.test(bodyLine)) {
|
|
108
|
+
hasLogging = true;
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (!hasLogging && !hasLoggingImport) {
|
|
113
|
+
vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
|
|
114
|
+
category: 'go-missing-sec-logging',
|
|
115
|
+
severity: 'medium',
|
|
116
|
+
confidence: 'medium',
|
|
117
|
+
message: `Missing security event logging in authentication function '${funcName}'`,
|
|
118
|
+
line: lineNumber,
|
|
119
|
+
suggestion: 'Log all authentication/authorization attempts with user ID, timestamp, and outcome',
|
|
120
|
+
owasp: 'A09:2025 - Security Logging and Monitoring Failures',
|
|
121
|
+
cwe: 'CWE-778',
|
|
122
|
+
pciDss: 'PCI DSS 10.2',
|
|
123
|
+
remediation: {
|
|
124
|
+
explanation: 'Security events must be logged for audit trails, incident response, and compliance. PCI DSS requires logging all authentication attempts, access to cardholder data, and administrative actions.',
|
|
125
|
+
before: `func Login(username, password string) error {\n if !validateCredentials(username, password) {\n return errors.New("invalid credentials")\n }\n return nil\n}`,
|
|
126
|
+
after: `func Login(username, password string) error {\n if !validateCredentials(username, password) {\n log.Printf("Failed login attempt for user: %s from IP: %s", username, getClientIP())\n return errors.New("invalid credentials")\n }\n log.Printf("Successful login for user: %s from IP: %s", username, getClientIP())\n return nil\n}`
|
|
127
|
+
},
|
|
128
|
+
attackVector: {
|
|
129
|
+
description: 'Without security event logging, attacks go undetected. Brute force attempts, privilege escalations, and unauthorized access leave no audit trail for investigation.',
|
|
130
|
+
exploitExample: `// Attacker attempts 1000 passwords:\nfor pwd in passwords:\n Login(username, pwd)\n// No logs = no detection = eventual success`,
|
|
131
|
+
realWorldImpact: [
|
|
132
|
+
'Brute force attacks go undetected',
|
|
133
|
+
'No audit trail for forensic investigation',
|
|
134
|
+
'Compliance violations (PCI DSS 10.2, SOC 2)',
|
|
135
|
+
'Cannot detect account takeover attempts',
|
|
136
|
+
'No evidence for incident response',
|
|
137
|
+
'Regulatory fines and penalties'
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// Also check for sensitive data access without logging
|
|
145
|
+
const isSensitiveDataAccess = /SELECT.*FROM.*(?:users|accounts|cards|payments|credentials)|UPDATE.*(?:users|accounts)/i.test(trimmed);
|
|
146
|
+
const isDBQuery = /db\.Query|db\.Exec|\.Find|\.Where/i.test(trimmed);
|
|
147
|
+
if (isSensitiveDataAccess && isDBQuery) {
|
|
148
|
+
// Look for logging in surrounding ±10 lines
|
|
149
|
+
let hasLogging = false;
|
|
150
|
+
const startLine = Math.max(0, index - 10);
|
|
151
|
+
const endLine = Math.min(lines.length, index + 10);
|
|
152
|
+
for (let i = startLine; i < endLine; i++) {
|
|
153
|
+
const contextLine = lines[i].trim();
|
|
154
|
+
if (/log\.|logrus\.|zap\.|zerolog\./i.test(contextLine)) {
|
|
155
|
+
hasLogging = true;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (!hasLogging && !hasLoggingImport) {
|
|
160
|
+
vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
|
|
161
|
+
category: 'go-missing-sec-logging',
|
|
162
|
+
severity: 'medium',
|
|
163
|
+
confidence: 'low',
|
|
164
|
+
message: 'Missing logging for sensitive data access',
|
|
165
|
+
line: lineNumber,
|
|
166
|
+
suggestion: 'Log access to sensitive data tables with user ID and timestamp',
|
|
167
|
+
owasp: 'A09:2025 - Security Logging and Monitoring Failures',
|
|
168
|
+
cwe: 'CWE-778',
|
|
169
|
+
pciDss: 'PCI DSS 10.2',
|
|
170
|
+
remediation: {
|
|
171
|
+
explanation: 'Access to sensitive data (user accounts, payment info, credentials) must be logged for audit compliance and security monitoring.',
|
|
172
|
+
before: `rows, err := db.Query("SELECT * FROM users WHERE role = 'admin'")\n// No audit trail of who accessed admin data`,
|
|
173
|
+
after: `log.Printf("Admin user query by: %s at: %v", currentUser, time.Now())\nrows, err := db.Query("SELECT * FROM users WHERE role = 'admin'")`
|
|
174
|
+
},
|
|
175
|
+
attackVector: {
|
|
176
|
+
description: 'Unlogged access to sensitive data prevents detection of insider threats, privilege abuse, and data exfiltration.',
|
|
177
|
+
exploitExample: `// Insider threat:\nfor all users:\n SELECT * FROM payment_cards WHERE user_id = ?\n// No logs = no detection`,
|
|
178
|
+
realWorldImpact: [
|
|
179
|
+
'Insider threats go undetected',
|
|
180
|
+
'Data exfiltration without audit trail',
|
|
181
|
+
'Compliance violations (GDPR Article 32, PCI DSS 10.2)',
|
|
182
|
+
'Cannot prove data breach scope',
|
|
183
|
+
'Regulatory investigations and fines'
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
}));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
return vulnerabilities;
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=error-handling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handling.js","sourceRoot":"","sources":["../../../../../../../../src/lib/analyzers/go/security-checks/error-handling.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAeH,gDA6MC;AAzND,sEAA6E;AAE7E;;;;;;;;;GASG;AACH,SAAgB,kBAAkB,CAAC,KAAe;IAChD,MAAM,eAAe,GAA4B,EAAE,CAAC;IACpD,IAAI,kBAAkB,GAAG,KAAK,CAAC;IAE/B,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,gBAAgB,GAAG,iCAAiC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAE7E,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC5B,MAAM,UAAU,GAAG,KAAK,GAAG,CAAC,CAAC;QAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAE5B,wCAAwC;QACxC,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,kBAAkB,GAAG,IAAI,CAAC;QAC5B,CAAC;QACD,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,kBAAkB,GAAG,KAAK,CAAC;YAC3B,OAAO;QACT,CAAC;QAED,gCAAgC;QAChC,IAAI,CAAC,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AAE,CAAC;gBACrC,eAAe,CAAC,IAAI,CAClB,IAAA,mDAA6B,EAAC;oBAC5B,QAAQ,EAAE,wBAAwB;oBAClC,QAAQ,EAAE,QAAQ;oBAClB,UAAU,EAAE,KAAK;oBACjB,OAAO,EAAE,2CAA2C;oBACpD,IAAI,EAAE,UAAU;oBAChB,UAAU,EAAE,gEAAgE;oBAC5E,KAAK,EAAE,qDAAqD;oBAC5D,GAAG,EAAE,SAAS;oBACd,MAAM,EAAE,cAAc;oBACtB,WAAW,EAAE;wBACX,WAAW,EACT,kIAAkI;wBACpI,MAAM,EAAE,iHAAiH;wBACzH,KAAK,EAAE,0IAA0I;qBAClJ;oBACD,YAAY,EAAE;wBACZ,WAAW,EACT,kHAAkH;wBACpH,cAAc,EAAE,kHAAkH;wBAClI,eAAe,EAAE;4BACf,+BAA+B;4BAC/B,uCAAuC;4BACvC,uDAAuD;4BACvD,gCAAgC;4BAChC,qCAAqC;yBACtC;qBACF;iBACF,CAAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go Injection Attack Security Checks
|
|
3
|
+
* OWASP A03:2025 - Injection
|
|
4
|
+
*
|
|
5
|
+
* Detects SQL injection, command injection, LDAP injection, NoSQL injection,
|
|
6
|
+
* and XXE vulnerabilities in Go code. These are among the most critical security risks.
|
|
7
|
+
*/
|
|
8
|
+
import { SecurityVulnerability } from '../../types';
|
|
9
|
+
/**
|
|
10
|
+
* Checks for injection attack vulnerabilities in Go code
|
|
11
|
+
*
|
|
12
|
+
* Covers:
|
|
13
|
+
* - Check #1: SQL Injection - String concatenation in database queries (CRITICAL)
|
|
14
|
+
* - Check #2: Command Injection - exec.Command with shell and user input (CRITICAL)
|
|
15
|
+
* - Check #3: LDAP Injection - Unsafe LDAP filter construction (HIGH)
|
|
16
|
+
* - Check #4: NoSQL Injection - MongoDB query construction with user input (HIGH)
|
|
17
|
+
* - Check #5: XXE - Unsafe XML parsing without DisallowDTD (HIGH)
|
|
18
|
+
* - Check #6: Template Injection - Unsafe template.HTML construction (HIGH)
|
|
19
|
+
*
|
|
20
|
+
* @param lines - Array of code lines
|
|
21
|
+
* @returns Array of security vulnerabilities found
|
|
22
|
+
*/
|
|
23
|
+
export declare function checkInjectionAttacks(lines: string[]): SecurityVulnerability[];
|
|
24
|
+
//# sourceMappingURL=injection-attacks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injection-attacks.d.ts","sourceRoot":"","sources":["../../../../../../../../src/lib/analyzers/go/security-checks/injection-attacks.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGpD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,qBAAqB,EAAE,CA6b9E"}
|