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.
Files changed (90) hide show
  1. package/__tests__/local-scanner.test.ts +5 -0
  2. package/dist/packages/cli/src/commands/scan.d.ts.map +1 -1
  3. package/dist/packages/cli/src/commands/scan.js +3 -1
  4. package/dist/packages/cli/src/commands/scan.js.map +1 -1
  5. package/dist/packages/cli/src/config/config-loader.d.ts +2 -2
  6. package/dist/packages/cli/src/config/config-loader.d.ts.map +1 -1
  7. package/dist/packages/cli/src/config/config-loader.js +2 -2
  8. package/dist/packages/cli/src/config/config-loader.js.map +1 -1
  9. package/dist/packages/cli/src/scanner/local-scanner.d.ts +2 -2
  10. package/dist/packages/cli/src/scanner/local-scanner.d.ts.map +1 -1
  11. package/dist/packages/cli/src/scanner/local-scanner.js +10 -1
  12. package/dist/packages/cli/src/scanner/local-scanner.js.map +1 -1
  13. package/dist/src/lib/analyzers/go/quality-checks/code-quality.d.ts +20 -0
  14. package/dist/src/lib/analyzers/go/quality-checks/code-quality.d.ts.map +1 -0
  15. package/dist/src/lib/analyzers/go/quality-checks/code-quality.js +211 -0
  16. package/dist/src/lib/analyzers/go/quality-checks/code-quality.js.map +1 -0
  17. package/dist/src/lib/analyzers/go/security-checks/access-control.d.ts +20 -0
  18. package/dist/src/lib/analyzers/go/security-checks/access-control.d.ts.map +1 -0
  19. package/dist/src/lib/analyzers/go/security-checks/access-control.js +201 -0
  20. package/dist/src/lib/analyzers/go/security-checks/access-control.js.map +1 -0
  21. package/dist/src/lib/analyzers/go/security-checks/ai-generated-code.d.ts +25 -0
  22. package/dist/src/lib/analyzers/go/security-checks/ai-generated-code.d.ts.map +1 -0
  23. package/dist/src/lib/analyzers/go/security-checks/ai-generated-code.js +545 -0
  24. package/dist/src/lib/analyzers/go/security-checks/ai-generated-code.js.map +1 -0
  25. package/dist/src/lib/analyzers/go/security-checks/concurrency-safety.d.ts +23 -0
  26. package/dist/src/lib/analyzers/go/security-checks/concurrency-safety.d.ts.map +1 -0
  27. package/dist/src/lib/analyzers/go/security-checks/concurrency-safety.js +321 -0
  28. package/dist/src/lib/analyzers/go/security-checks/concurrency-safety.js.map +1 -0
  29. package/dist/src/lib/analyzers/go/security-checks/credentials-crypto.d.ts +22 -0
  30. package/dist/src/lib/analyzers/go/security-checks/credentials-crypto.d.ts.map +1 -0
  31. package/dist/src/lib/analyzers/go/security-checks/credentials-crypto.js +267 -0
  32. package/dist/src/lib/analyzers/go/security-checks/credentials-crypto.js.map +1 -0
  33. package/dist/src/lib/analyzers/go/security-checks/deserialization.d.ts +19 -0
  34. package/dist/src/lib/analyzers/go/security-checks/deserialization.d.ts.map +1 -0
  35. package/dist/src/lib/analyzers/go/security-checks/deserialization.js +210 -0
  36. package/dist/src/lib/analyzers/go/security-checks/deserialization.js.map +1 -0
  37. package/dist/src/lib/analyzers/go/security-checks/error-handling.d.ts +19 -0
  38. package/dist/src/lib/analyzers/go/security-checks/error-handling.d.ts.map +1 -0
  39. package/dist/src/lib/analyzers/go/security-checks/error-handling.js +192 -0
  40. package/dist/src/lib/analyzers/go/security-checks/error-handling.js.map +1 -0
  41. package/dist/src/lib/analyzers/go/security-checks/injection-attacks.d.ts +24 -0
  42. package/dist/src/lib/analyzers/go/security-checks/injection-attacks.d.ts.map +1 -0
  43. package/dist/src/lib/analyzers/go/security-checks/injection-attacks.js +401 -0
  44. package/dist/src/lib/analyzers/go/security-checks/injection-attacks.js.map +1 -0
  45. package/dist/src/lib/analyzers/go/security-checks/ssrf-detection.d.ts +19 -0
  46. package/dist/src/lib/analyzers/go/security-checks/ssrf-detection.d.ts.map +1 -0
  47. package/dist/src/lib/analyzers/go/security-checks/ssrf-detection.js +252 -0
  48. package/dist/src/lib/analyzers/go/security-checks/ssrf-detection.js.map +1 -0
  49. package/dist/src/lib/analyzers/go/security-checks/tls-configuration.d.ts +19 -0
  50. package/dist/src/lib/analyzers/go/security-checks/tls-configuration.d.ts.map +1 -0
  51. package/dist/src/lib/analyzers/go/security-checks/tls-configuration.js +112 -0
  52. package/dist/src/lib/analyzers/go/security-checks/tls-configuration.js.map +1 -0
  53. package/dist/src/lib/analyzers/go/security-checks/web-security.d.ts +22 -0
  54. package/dist/src/lib/analyzers/go/security-checks/web-security.d.ts.map +1 -0
  55. package/dist/src/lib/analyzers/go/security-checks/web-security.js +244 -0
  56. package/dist/src/lib/analyzers/go/security-checks/web-security.js.map +1 -0
  57. package/dist/src/lib/analyzers/go/utils/createVulnerability.d.ts +58 -0
  58. package/dist/src/lib/analyzers/go/utils/createVulnerability.d.ts.map +1 -0
  59. package/dist/src/lib/analyzers/go/utils/createVulnerability.js +71 -0
  60. package/dist/src/lib/analyzers/go/utils/createVulnerability.js.map +1 -0
  61. package/dist/src/lib/analyzers/go-analyzer.d.ts +48 -0
  62. package/dist/src/lib/analyzers/go-analyzer.d.ts.map +1 -0
  63. package/dist/src/lib/analyzers/go-analyzer.js +233 -0
  64. package/dist/src/lib/analyzers/go-analyzer.js.map +1 -0
  65. package/dist/src/lib/analyzers/helpers/ai-code-detection-utils.d.ts.map +1 -1
  66. package/dist/src/lib/analyzers/helpers/ai-code-detection-utils.js +1 -0
  67. package/dist/src/lib/analyzers/helpers/ai-code-detection-utils.js.map +1 -1
  68. package/dist/src/lib/analyzers/python/security-checks/injection-attacks.d.ts +5 -3
  69. package/dist/src/lib/analyzers/python/security-checks/injection-attacks.d.ts.map +1 -1
  70. package/dist/src/lib/analyzers/python/security-checks/injection-attacks.js +23 -5
  71. package/dist/src/lib/analyzers/python/security-checks/injection-attacks.js.map +1 -1
  72. package/dist/src/lib/analyzers/python-analyzer.d.ts.map +1 -1
  73. package/dist/src/lib/analyzers/python-analyzer.js +17 -1
  74. package/dist/src/lib/analyzers/python-analyzer.js.map +1 -1
  75. package/dist/src/lib/analyzers/secrets/secrets-analyzer.d.ts +1 -1
  76. package/dist/src/lib/analyzers/secrets/secrets-analyzer.d.ts.map +1 -1
  77. package/dist/src/lib/analyzers/secrets/secrets-analyzer.js.map +1 -1
  78. package/dist/src/lib/security/compliance-mapping.d.ts.map +1 -1
  79. package/dist/src/lib/security/compliance-mapping.js +403 -0
  80. package/dist/src/lib/security/compliance-mapping.js.map +1 -1
  81. package/dist/src/lib/security/severity-scoring.d.ts.map +1 -1
  82. package/dist/src/lib/security/severity-scoring.js +169 -0
  83. package/dist/src/lib/security/severity-scoring.js.map +1 -1
  84. package/dist/src/lib/types/index.d.ts +2 -2
  85. package/dist/src/lib/types/index.d.ts.map +1 -1
  86. package/example3.go +23 -0
  87. package/package.json +1 -1
  88. package/src/commands/scan.ts +3 -1
  89. package/src/config/config-loader.ts +3 -3
  90. package/src/scanner/local-scanner.ts +13 -2
@@ -0,0 +1,545 @@
1
+ "use strict";
2
+ /**
3
+ * Go AI-Generated Code Detection Module
4
+ *
5
+ * Detects AI-generated code patterns as SECURITY RISKS:
6
+ * - 12 Go-specific hallucination patterns (JavaScript/Python influence)
7
+ * - 8 code smell heuristics (over-engineering, inconsistency)
8
+ * - Confidence scoring (HIGH/MEDIUM/LOW)
9
+ *
10
+ * OWASP A04:2025 - Insecure Design
11
+ * CWE-1120 - Excessive Code Complexity
12
+ * CWE-758 - Reliance on Undefined Behavior
13
+ *
14
+ * Phase 2, Day 7 (Go Language Support - AI Code Detection)
15
+ * Created: January 19, 2026
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.checkAIGeneratedCode = checkAIGeneratedCode;
19
+ const createVulnerability_1 = require("../utils/createVulnerability");
20
+ const ai_code_detection_utils_1 = require("../../helpers/ai-code-detection-utils");
21
+ /**
22
+ * Go standard library packages (comprehensive list)
23
+ *
24
+ * Any import not in this list is likely an AI hallucination.
25
+ * Source: https://pkg.go.dev/std (Go 1.21+)
26
+ */
27
+ const GO_STANDARD_LIBRARY = new Set([
28
+ // Core packages
29
+ 'archive/tar', 'archive/zip',
30
+ 'bufio', 'builtin', 'bytes',
31
+ 'compress/bzip2', 'compress/flate', 'compress/gzip', 'compress/lzw', 'compress/zlib',
32
+ 'container/heap', 'container/list', 'container/ring',
33
+ 'context',
34
+ 'crypto', 'crypto/aes', 'crypto/cipher', 'crypto/des', 'crypto/dsa', 'crypto/ecdh', 'crypto/ecdsa',
35
+ 'crypto/ed25519', 'crypto/elliptic', 'crypto/hmac', 'crypto/md5', 'crypto/rand', 'crypto/rc4',
36
+ 'crypto/rsa', 'crypto/sha1', 'crypto/sha256', 'crypto/sha512', 'crypto/subtle', 'crypto/tls',
37
+ 'crypto/x509', 'crypto/x509/pkix',
38
+ 'database/sql', 'database/sql/driver',
39
+ 'debug/buildinfo', 'debug/dwarf', 'debug/elf', 'debug/gosym', 'debug/macho', 'debug/pe', 'debug/plan9obj',
40
+ 'embed',
41
+ 'encoding', 'encoding/ascii85', 'encoding/asn1', 'encoding/base32', 'encoding/base64',
42
+ 'encoding/binary', 'encoding/csv', 'encoding/gob', 'encoding/hex', 'encoding/json',
43
+ 'encoding/pem', 'encoding/xml',
44
+ 'errors',
45
+ 'expvar',
46
+ 'flag',
47
+ 'fmt',
48
+ 'go/ast', 'go/build', 'go/build/constraint', 'go/constant', 'go/doc', 'go/doc/comment',
49
+ 'go/format', 'go/importer', 'go/parser', 'go/printer', 'go/scanner', 'go/token', 'go/types',
50
+ 'hash', 'hash/adler32', 'hash/crc32', 'hash/crc64', 'hash/fnv', 'hash/maphash',
51
+ 'html', 'html/template',
52
+ 'image', 'image/color', 'image/color/palette', 'image/draw', 'image/gif', 'image/jpeg', 'image/png',
53
+ 'index/suffixarray',
54
+ 'io', 'io/fs', 'io/ioutil',
55
+ 'log', 'log/slog', 'log/syslog',
56
+ 'math', 'math/big', 'math/bits', 'math/cmplx', 'math/rand',
57
+ 'mime', 'mime/multipart', 'mime/quotedprintable',
58
+ 'net', 'net/http', 'net/http/cgi', 'net/http/cookiejar', 'net/http/fcgi', 'net/http/httptest',
59
+ 'net/http/httptrace', 'net/http/httputil', 'net/http/pprof',
60
+ 'net/mail', 'net/netip', 'net/rpc', 'net/rpc/jsonrpc', 'net/smtp', 'net/textproto', 'net/url',
61
+ 'os', 'os/exec', 'os/signal', 'os/user',
62
+ 'path', 'path/filepath',
63
+ 'plugin',
64
+ 'reflect',
65
+ 'regexp', 'regexp/syntax',
66
+ 'runtime', 'runtime/cgo', 'runtime/coverage', 'runtime/debug', 'runtime/metrics', 'runtime/pprof', 'runtime/trace',
67
+ 'slices',
68
+ 'sort',
69
+ 'strconv',
70
+ 'strings',
71
+ 'sync', 'sync/atomic',
72
+ 'syscall', 'syscall/js',
73
+ 'testing', 'testing/fstest', 'testing/iotest', 'testing/quick', 'testing/slogtest',
74
+ 'text/scanner', 'text/tabwriter', 'text/template', 'text/template/parse',
75
+ 'time', 'time/tzdata',
76
+ 'unicode', 'unicode/utf16', 'unicode/utf8',
77
+ 'unsafe',
78
+ // Golang.org/x (commonly used, often confused as standard)
79
+ 'golang.org/x/crypto', 'golang.org/x/net', 'golang.org/x/text', 'golang.org/x/tools',
80
+ 'golang.org/x/crypto/bcrypt', 'golang.org/x/crypto/ssh', 'golang.org/x/net/html',
81
+ ]);
82
+ /**
83
+ * Go hallucination patterns (12 patterns)
84
+ *
85
+ * AI code generators hallucinate methods from JavaScript/Python:
86
+ * - JavaScript influence: string.toUpperCase(), array.push(), string.charAt()
87
+ * - Python influence: string.upper(), list.append()
88
+ * - Non-existent methods: string.contains(), string.isEmpty()
89
+ */
90
+ const HALLUCINATION_PATTERNS = new Map([
91
+ // JavaScript-style string methods in Go
92
+ ['toUpperCase', {
93
+ correct: 'strings.ToUpper()',
94
+ description: 'Go uses strings.ToUpper(s), not s.toUpperCase(). This is JavaScript syntax.'
95
+ }],
96
+ ['toLowerCase', {
97
+ correct: 'strings.ToLower()',
98
+ description: 'Go uses strings.ToLower(s), not s.toLowerCase(). This is JavaScript syntax.'
99
+ }],
100
+ ['indexOf', {
101
+ correct: 'strings.Index()',
102
+ description: 'Go uses strings.Index(s, substr), not s.indexOf(). This is JavaScript syntax.'
103
+ }],
104
+ ['charAt', {
105
+ correct: '[index]',
106
+ description: 'Go uses indexing s[index], not s.charAt(). This is JavaScript syntax.'
107
+ }],
108
+ ['substring', {
109
+ correct: '[start:end]',
110
+ description: 'Go uses slice notation s[start:end], not s.substring(). This is JavaScript syntax.'
111
+ }],
112
+ // Python-style methods in Go
113
+ ['upper', {
114
+ correct: 'strings.ToUpper()',
115
+ description: 'Go uses strings.ToUpper(s), not s.upper(). This is Python syntax.'
116
+ }],
117
+ ['lower', {
118
+ correct: 'strings.ToLower()',
119
+ description: 'Go uses strings.ToLower(s), not s.lower(). This is Python syntax.'
120
+ }],
121
+ ['append', {
122
+ correct: 'built-in append()',
123
+ description: 'Go uses built-in append(slice, elem), not slice.append(). This is Python syntax.'
124
+ }],
125
+ // Non-existent Go methods (AI hallucinations)
126
+ ['contains', {
127
+ correct: 'strings.Contains()',
128
+ description: 'Go uses strings.Contains(s, substr), not s.contains(). Method does not exist on strings.'
129
+ }],
130
+ ['isEmpty', {
131
+ correct: 'len(s) == 0',
132
+ description: 'Go uses len(s) == 0, not s.isEmpty(). Method does not exist.'
133
+ }],
134
+ ['size', {
135
+ correct: 'len()',
136
+ description: 'Go uses len() built-in function, not .size(). This is Java/Python syntax.'
137
+ }],
138
+ ['length', {
139
+ correct: 'len()',
140
+ description: 'Go uses len() built-in function, not .length property. This is JavaScript syntax.'
141
+ }],
142
+ ]);
143
+ /**
144
+ * Checks for AI-generated code patterns in Go code
145
+ *
146
+ * @param lines - Array of code lines
147
+ * @param filename - Name of the file being analyzed
148
+ * @returns Array of security vulnerabilities found
149
+ */
150
+ function checkAIGeneratedCode(lines, filename = '') {
151
+ const vulnerabilities = [];
152
+ // Skip test files (AI-generated tests are less critical)
153
+ if ((0, ai_code_detection_utils_1.isTestFile)(filename)) {
154
+ return vulnerabilities;
155
+ }
156
+ const code = lines.join('\n');
157
+ const cleanedCode = (0, ai_code_detection_utils_1.removeCommentsAndStrings)(code, 'go');
158
+ const cleanedLines = cleanedCode.split('\n');
159
+ // Track hallucination detections
160
+ const hallucinationsDetected = [];
161
+ // Track imports and their aliases for package validation
162
+ const importedPackages = new Map();
163
+ // =============================================================================
164
+ // IMPORT PACKAGE VALIDATION (Detect non-existent packages)
165
+ // =============================================================================
166
+ // Track if we're inside an import block
167
+ let inImportBlock = false;
168
+ lines.forEach((line, index) => {
169
+ const lineNumber = index + 1;
170
+ const trimmed = line.trim();
171
+ // Skip comments and empty lines
172
+ if (!trimmed || trimmed.startsWith('//') || trimmed.startsWith('/*')) {
173
+ return;
174
+ }
175
+ // Detect import block start
176
+ if (/^import\s*\(/.test(trimmed)) {
177
+ inImportBlock = true;
178
+ return;
179
+ }
180
+ // Detect import block end
181
+ if (inImportBlock && trimmed === ')') {
182
+ inImportBlock = false;
183
+ return;
184
+ }
185
+ // Single import: import "package/name"
186
+ const singleImportMatch = trimmed.match(/^import\s+"([^"]+)"/);
187
+ if (singleImportMatch) {
188
+ const packagePath = singleImportMatch[1];
189
+ const packageName = packagePath.split('/').pop() || packagePath;
190
+ importedPackages.set(packageName, { packagePath, alias: packageName, line: lineNumber });
191
+ return;
192
+ }
193
+ // Aliased import: import alias "package/name"
194
+ const aliasImportMatch = trimmed.match(/^import\s+(\w+)\s+"([^"]+)"/);
195
+ if (aliasImportMatch) {
196
+ const alias = aliasImportMatch[1];
197
+ const packagePath = aliasImportMatch[2];
198
+ importedPackages.set(alias, { packagePath, alias, line: lineNumber });
199
+ return;
200
+ }
201
+ // Inside import block: "package/name"
202
+ if (inImportBlock) {
203
+ const blockImportMatch = trimmed.match(/^"([^"]+)"/);
204
+ if (blockImportMatch) {
205
+ const packagePath = blockImportMatch[1];
206
+ const packageName = packagePath.split('/').pop() || packagePath;
207
+ importedPackages.set(packageName, { packagePath, alias: packageName, line: lineNumber });
208
+ return;
209
+ }
210
+ // Aliased in block: alias "package/name"
211
+ const blockAliasMatch = trimmed.match(/^(\w+)\s+"([^"]+)"/);
212
+ if (blockAliasMatch) {
213
+ const alias = blockAliasMatch[1];
214
+ const packagePath = blockAliasMatch[2];
215
+ importedPackages.set(alias, { packagePath, alias, line: lineNumber });
216
+ return;
217
+ }
218
+ }
219
+ });
220
+ // Validate each imported package against Go standard library
221
+ importedPackages.forEach((importInfo, alias) => {
222
+ const { packagePath, line } = importInfo;
223
+ // Skip blank imports (side effects only)
224
+ if (alias === '_') {
225
+ return;
226
+ }
227
+ // Check if package exists in standard library
228
+ // Skip third-party packages (github.com, gopkg.in, etc.)
229
+ const isThirdParty = packagePath.includes('github.com') ||
230
+ packagePath.includes('gitlab.com') ||
231
+ packagePath.includes('gopkg.in') ||
232
+ packagePath.includes('bitbucket.org');
233
+ if (!isThirdParty && !GO_STANDARD_LIBRARY.has(packagePath)) {
234
+ hallucinationsDetected.push(`package:${packagePath}`);
235
+ vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
236
+ category: 'go-ai-hallucination',
237
+ severity: 'critical',
238
+ confidence: 'high',
239
+ message: `AI hallucination detected: Package "${packagePath}" does not exist in Go standard library`,
240
+ line,
241
+ suggestion: `Remove this import or check the correct package name. Common mistakes: "html/sanitize" (use "html" + "html/template"), "crypto/random" (use "crypto/rand"), "ldap/client" (use third-party "github.com/go-ldap/ldap")`,
242
+ owasp: 'A04:2025 - Insecure Design',
243
+ cwe: 'CWE-758',
244
+ pciDss: 'N/A',
245
+ remediation: {
246
+ explanation: `The package "${packagePath}" does not exist in Go's standard library. This is likely AI-generated code that hallucinated a package name. Check the official Go standard library documentation at https://pkg.go.dev/std`,
247
+ before: `import "${packagePath}" // AI hallucination - does not exist`,
248
+ after: `// Use the correct Go standard library package:\n// For HTML sanitization: import "html" and "html/template"\n// For cryptographic random: import "crypto/rand"\n// For LDAP: use third-party "github.com/go-ldap/ldap"`
249
+ },
250
+ attackVector: {
251
+ description: 'Non-existent package imports indicate AI-generated code that has never been compiled or tested. This code will fail to build and likely contains other hallucinated methods and logic.',
252
+ exploitExample: `import "${packagePath}"\n// Compilation error: package ${packagePath} is not in std`,
253
+ realWorldImpact: [
254
+ 'Build failures from non-existent packages',
255
+ 'Code has never been compiled or run',
256
+ 'Likely contains other AI-generated bugs',
257
+ 'Security vulnerabilities from untested code paths',
258
+ 'Indicates entire codebase may be AI-generated without review'
259
+ ]
260
+ }
261
+ }));
262
+ }
263
+ });
264
+ // =============================================================================
265
+ // HALLUCINATION DETECTION (12 Go-specific method patterns)
266
+ // =============================================================================
267
+ lines.forEach((line, index) => {
268
+ const lineNumber = index + 1;
269
+ const trimmed = line.trim();
270
+ // Skip comments and empty lines
271
+ if (!trimmed || trimmed.startsWith('//') || trimmed.startsWith('/*')) {
272
+ return;
273
+ }
274
+ // Check for each hallucination pattern
275
+ HALLUCINATION_PATTERNS.forEach((pattern, method) => {
276
+ // Properties (no parentheses): length, size
277
+ const isProperty = method === 'length' || method === 'size';
278
+ // Pattern: variable.method() for methods, variable.property for properties
279
+ // Case-sensitive to avoid false positives (strings.Contains vs strings.contains)
280
+ const regex = isProperty
281
+ ? new RegExp(`\\w+\\.${method}(?!\\w)`) // Property access (no parens, case-sensitive)
282
+ : new RegExp(`\\w+\\.${method}\\s*\\(`);
283
+ if (regex.test(trimmed)) {
284
+ hallucinationsDetected.push(method);
285
+ vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
286
+ category: 'go-ai-hallucination',
287
+ severity: 'critical',
288
+ confidence: 'high',
289
+ message: `AI hallucination detected: .${method}${isProperty ? '' : '()'} does not exist in Go`,
290
+ line: lineNumber,
291
+ suggestion: `Use ${pattern.correct} instead. ${pattern.description}`,
292
+ owasp: 'A04:2025 - Insecure Design',
293
+ cwe: 'CWE-758',
294
+ pciDss: 'N/A',
295
+ remediation: {
296
+ explanation: pattern.description,
297
+ before: `str.${method}${isProperty ? '' : '()'} // AI hallucination - does not compile`,
298
+ after: pattern.correct
299
+ },
300
+ attackVector: {
301
+ description: 'AI-generated code with hallucinated methods will not compile, causing build failures. More critically, it indicates the code was not written by a human developer and has not been tested.',
302
+ exploitExample: `// AI hallucination:\nresult := username.${method}${isProperty ? '' : '()'}\n// Compilation error: ${method} not defined`,
303
+ realWorldImpact: [
304
+ 'Build failures from non-existent methods',
305
+ 'Code has never been tested or run',
306
+ 'Likely contains other AI-generated bugs',
307
+ 'Security vulnerabilities from untested code paths',
308
+ 'Maintenance burden from incorrect patterns'
309
+ ]
310
+ }
311
+ }));
312
+ }
313
+ });
314
+ });
315
+ // =============================================================================
316
+ // METHOD CALLS ON NON-EXISTENT PACKAGES
317
+ // =============================================================================
318
+ // Detect method calls on packages that don't exist (e.g., sanitize.HTML() from "html/sanitize")
319
+ lines.forEach((line, index) => {
320
+ const lineNumber = index + 1;
321
+ const trimmed = line.trim();
322
+ // Skip comments and empty lines
323
+ if (!trimmed || trimmed.startsWith('//') || trimmed.startsWith('/*')) {
324
+ return;
325
+ }
326
+ // Pattern: packageName.MethodName() - detect any method call on a package
327
+ const methodCallMatch = trimmed.match(/(\w+)\.(\w+)\s*\(/g);
328
+ if (methodCallMatch) {
329
+ methodCallMatch.forEach(call => {
330
+ const parts = call.match(/(\w+)\.(\w+)\s*\(/);
331
+ if (!parts)
332
+ return;
333
+ const packageAlias = parts[1];
334
+ const methodName = parts[2];
335
+ // Check if this package alias is from a non-existent import
336
+ const importInfo = importedPackages.get(packageAlias);
337
+ if (importInfo) {
338
+ // Case 1: Package was imported, but doesn't exist in Go stdlib
339
+ const { packagePath } = importInfo;
340
+ // Skip third-party packages
341
+ const isThirdParty = packagePath.includes('github.com') ||
342
+ packagePath.includes('gitlab.com') ||
343
+ packagePath.includes('gopkg.in') ||
344
+ packagePath.includes('bitbucket.org');
345
+ // If package doesn't exist, report method call as hallucination
346
+ if (!isThirdParty && !GO_STANDARD_LIBRARY.has(packagePath)) {
347
+ hallucinationsDetected.push(`method:${packageAlias}.${methodName}`);
348
+ vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
349
+ category: 'go-ai-hallucination',
350
+ severity: 'critical',
351
+ confidence: 'high',
352
+ message: `AI hallucination detected: Method ${packageAlias}.${methodName}() called on non-existent package "${packagePath}"`,
353
+ line: lineNumber,
354
+ suggestion: `Package "${packagePath}" does not exist. Remove this code or use the correct Go standard library package.`,
355
+ owasp: 'A04:2025 - Insecure Design',
356
+ cwe: 'CWE-758',
357
+ pciDss: 'N/A',
358
+ remediation: {
359
+ explanation: `The method call ${packageAlias}.${methodName}() is from package "${packagePath}" which does not exist in Go's standard library. This is AI-generated code that has never been tested.`,
360
+ before: `${packageAlias}.${methodName}() // AI hallucination - package doesn't exist`,
361
+ after: `// Use the correct Go standard library:\n// For HTML sanitization: html.EscapeString() or template.HTMLEscapeString()\n// For crypto random: rand.Read() from "crypto/rand"`
362
+ },
363
+ attackVector: {
364
+ description: 'Method calls on non-existent packages indicate AI-generated code that will not compile. This code has never been tested and likely contains critical security vulnerabilities.',
365
+ exploitExample: `${packageAlias}.${methodName}()\n// Compilation error: package ${packagePath} is not in std`,
366
+ realWorldImpact: [
367
+ 'Build failures from method calls on non-existent packages',
368
+ 'Code has never been compiled or run',
369
+ 'Security vulnerabilities from untested logic',
370
+ 'Complete lack of code review or testing',
371
+ 'High risk of additional AI hallucinations in surrounding code'
372
+ ]
373
+ }
374
+ }));
375
+ }
376
+ }
377
+ else {
378
+ // Case 2: Package was NEVER imported - undefined identifier
379
+ // Check if it looks like a package (not a variable)
380
+ // Skip common Go built-ins and variables that might have methods
381
+ const skipList = ['err', 'ctx', 'req', 'resp', 'w', 'r', 'db', 'tx', 'conn', 'client',
382
+ 'config', 'logger', 'cache', 'session', 'user', 'data', 'result',
383
+ 'response', 'request', 'handler', 'server', 'router', 'app'];
384
+ // Skip if it's likely a variable name (lowercase first letter and in skip list)
385
+ const isLikelyVariable = /^[a-z]/.test(packageAlias) && skipList.includes(packageAlias.toLowerCase());
386
+ if (!isLikelyVariable) {
387
+ // Check if this looks like a package name that should exist
388
+ // Common hallucinations: crypto.X, html.X, strings.X without importing
389
+ const commonPackages = ['crypto', 'html', 'strings', 'json', 'xml', 'http', 'sql',
390
+ 'rand', 'time', 'sync', 'atomic', 'context', 'errors',
391
+ 'fmt', 'io', 'os', 'log', 'net', 'url', 'path', 'filepath'];
392
+ if (commonPackages.includes(packageAlias.toLowerCase())) {
393
+ hallucinationsDetected.push(`undefined:${packageAlias}.${methodName}`);
394
+ vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
395
+ category: 'go-ai-hallucination',
396
+ severity: 'critical',
397
+ confidence: 'high',
398
+ message: `AI hallucination detected: Method ${packageAlias}.${methodName}() called on undefined package "${packageAlias}" (never imported)`,
399
+ line: lineNumber,
400
+ suggestion: `Package "${packageAlias}" was never imported. Add the correct import or check if you meant a different package. Common mistake: using "crypto" when "crypto/rand" was imported (should use "rand.${methodName}()")`,
401
+ owasp: 'A04:2025 - Insecure Design',
402
+ cwe: 'CWE-758',
403
+ pciDss: 'N/A',
404
+ remediation: {
405
+ explanation: `The package "${packageAlias}" was never imported. This is likely AI-generated code that confused package import paths with package names. In Go, when you import "crypto/rand", the package name is "rand", not "crypto".`,
406
+ before: `import "crypto/random"\n...\nsessionToken := crypto.RandomString(32) // Wrong: 'crypto' not imported`,
407
+ after: `import "crypto/rand"\n...\ntoken := make([]byte, 32)\nrand.Read(token) // Correct: use 'rand' (from crypto/rand) with proper method`
408
+ },
409
+ attackVector: {
410
+ description: 'Method calls on undefined packages indicate AI-generated code that will not compile. The AI confused import paths with package names, a common hallucination pattern.',
411
+ exploitExample: `${packageAlias}.${methodName}()\n// Compilation error: undefined: ${packageAlias}`,
412
+ realWorldImpact: [
413
+ 'Build failures from undefined identifiers',
414
+ 'Code has never been compiled or tested',
415
+ 'AI confusion between import paths and package names',
416
+ 'Indicates lack of understanding of Go package system',
417
+ 'High probability of other AI-generated errors'
418
+ ]
419
+ }
420
+ }));
421
+ }
422
+ }
423
+ }
424
+ });
425
+ }
426
+ });
427
+ // =============================================================================
428
+ // CODE SMELL HEURISTICS (8 patterns from shared utilities)
429
+ // =============================================================================
430
+ const codeSmells = [];
431
+ // Heuristic 1: Over-engineered error handling (30+ points)
432
+ const errorHandlingScore = (0, ai_code_detection_utils_1.detectOverEngineeredErrorHandling)(cleanedLines);
433
+ if (errorHandlingScore > 0) {
434
+ codeSmells.push({ name: 'over-engineered-error-handling', score: errorHandlingScore });
435
+ }
436
+ // Heuristic 2: Unnecessary wrappers (25+ points)
437
+ const wrappersScore = (0, ai_code_detection_utils_1.detectUnnecessaryWrappers)(cleanedLines);
438
+ if (wrappersScore > 0) {
439
+ codeSmells.push({ name: 'unnecessary-wrappers', score: wrappersScore });
440
+ }
441
+ // Heuristic 3: Verbose comments (20+ points)
442
+ const commentsScore = (0, ai_code_detection_utils_1.detectVerboseComments)(lines);
443
+ if (commentsScore > 0) {
444
+ codeSmells.push({ name: 'verbose-comments', score: commentsScore });
445
+ }
446
+ // Heuristic 4: Mixed naming conventions (15+ points)
447
+ const namingScore = (0, ai_code_detection_utils_1.detectMixedNamingConventions)(cleanedLines);
448
+ if (namingScore > 0) {
449
+ codeSmells.push({ name: 'mixed-naming', score: namingScore });
450
+ }
451
+ // Heuristic 5: Redundant nil checks (10+ points)
452
+ const nullChecksScore = (0, ai_code_detection_utils_1.detectRedundantNullChecks)(cleanedLines);
453
+ if (nullChecksScore > 0) {
454
+ codeSmells.push({ name: 'redundant-nil-checks', score: nullChecksScore });
455
+ }
456
+ // Heuristic 6: Unnecessary goroutines (10+ points) - Go-specific
457
+ const unnecessaryGoroutinesScore = detectUnnecessaryGoroutines(cleanedCode);
458
+ if (unnecessaryGoroutinesScore > 0) {
459
+ codeSmells.push({ name: 'unnecessary-goroutines', score: unnecessaryGoroutinesScore });
460
+ }
461
+ // Heuristic 7: Generic variable overuse (15+ points)
462
+ const genericVarsScore = (0, ai_code_detection_utils_1.detectGenericVariableOveruse)(cleanedLines);
463
+ if (genericVarsScore > 0) {
464
+ codeSmells.push({ name: 'generic-variables', score: genericVarsScore });
465
+ }
466
+ // Heuristic 8: Inconsistent string concatenation (10+ points)
467
+ const stringConcatScore = (0, ai_code_detection_utils_1.detectInconsistentStringConcatenation)(cleanedLines);
468
+ if (stringConcatScore > 0) {
469
+ codeSmells.push({ name: 'inconsistent-strings', score: stringConcatScore });
470
+ }
471
+ // =============================================================================
472
+ // CONFIDENCE SCORING & REPORTING
473
+ // =============================================================================
474
+ // Convert code smells array to HeuristicScores object
475
+ const heuristicScores = {
476
+ overEngineeredErrors: codeSmells.find(s => s.name === 'over-engineered-error-handling')?.score || 0,
477
+ unnecessaryWrappers: codeSmells.find(s => s.name === 'unnecessary-wrappers')?.score || 0,
478
+ verboseComments: codeSmells.find(s => s.name === 'verbose-comments')?.score || 0,
479
+ mixedNaming: codeSmells.find(s => s.name === 'mixed-naming')?.score || 0,
480
+ redundantNullChecks: codeSmells.find(s => s.name === 'redundant-nil-checks')?.score || 0,
481
+ unnecessaryAsync: 0, // Not applicable to Go
482
+ genericVariables: codeSmells.find(s => s.name === 'generic-variables')?.score || 0,
483
+ inconsistentStrings: codeSmells.find(s => s.name === 'inconsistent-strings')?.score || 0,
484
+ };
485
+ const confidence = (0, ai_code_detection_utils_1.calculateAICodeConfidence)(hallucinationsDetected.length, heuristicScores);
486
+ // Report code smell summary if medium/high confidence
487
+ if (confidence && confidence.confidence !== 'LOW' && codeSmells.length > 0) {
488
+ const severity = confidence.confidence === 'HIGH' ? 'high' : 'medium';
489
+ vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
490
+ category: 'go-ai-code-smell',
491
+ severity,
492
+ confidence: confidence.confidence.toLowerCase(),
493
+ message: `AI-generated code detected (${confidence.confidence} confidence, score: ${confidence.heuristicScore})`,
494
+ line: 1,
495
+ suggestion: 'Review code for over-engineering, verbose comments, and mixed conventions. AI-generated code should be tested and refactored.',
496
+ owasp: 'A04:2025 - Insecure Design',
497
+ cwe: 'CWE-1120',
498
+ pciDss: 'N/A',
499
+ remediation: {
500
+ explanation: 'AI-generated code often exhibits patterns like over-engineered error handling, unnecessary abstractions, verbose comments, and mixed naming conventions. This code should be thoroughly reviewed and tested.',
501
+ before: `// AI-generated characteristics:\n// - Verbose comments\n// - Unnecessary wrappers\n// - Mixed naming (snake_case + camelCase)\n// - Over-engineered error handling`,
502
+ after: `// Human-refactored code:\n// - Concise comments only where needed\n// - Direct implementations\n// - Consistent Go naming (camelCase)\n// - Simple error handling`
503
+ },
504
+ attackVector: {
505
+ description: 'AI-generated code may contain subtle bugs, inefficiencies, or security vulnerabilities that were not caught by testing. The code patterns indicate it was not written by an experienced Go developer.',
506
+ exploitExample: 'Code smells detected: ' + codeSmells.map(s => s.name).join(', '),
507
+ realWorldImpact: [
508
+ 'Untested code paths with potential bugs',
509
+ 'Over-engineered solutions reducing maintainability',
510
+ 'Performance issues from unnecessary abstractions',
511
+ 'Security vulnerabilities from AI hallucinations',
512
+ 'Technical debt from non-idiomatic Go code'
513
+ ]
514
+ }
515
+ }));
516
+ }
517
+ return vulnerabilities;
518
+ }
519
+ /**
520
+ * Detects unnecessary goroutines (Go-specific heuristic)
521
+ *
522
+ * Patterns:
523
+ * - Single-line goroutines that could be synchronous
524
+ * - Goroutines without any channel/sync usage
525
+ * - Goroutines that only call one function
526
+ *
527
+ * @param code - Code to analyze
528
+ * @returns Score (10+ points indicates AI pattern)
529
+ */
530
+ function detectUnnecessaryGoroutines(code) {
531
+ let score = 0;
532
+ // Pattern: go functionCall() with no channels or sync
533
+ const singleLineGoroutines = code.match(/go\s+\w+\s*\([^)]*\)/g) || [];
534
+ singleLineGoroutines.forEach(goroutine => {
535
+ // Check if there's any channel or sync usage nearby (within 100 chars)
536
+ const contextStart = Math.max(0, code.indexOf(goroutine) - 100);
537
+ const contextEnd = Math.min(code.length, code.indexOf(goroutine) + 100);
538
+ const context = code.substring(contextStart, contextEnd);
539
+ if (!/chan|sync\.|<-|WaitGroup/.test(context)) {
540
+ score += 5; // Suspicious: goroutine with no concurrency primitives
541
+ }
542
+ });
543
+ return score;
544
+ }
545
+ //# sourceMappingURL=ai-generated-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-generated-code.js","sourceRoot":"","sources":["../../../../../../../../src/lib/analyzers/go/security-checks/ai-generated-code.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AA+JH,oDAsbC;AAllBD,sEAA6E;AAC7E,mFAY+C;AAU/C;;;;;GAKG;AACH,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAS;IAC1C,gBAAgB;IAChB,aAAa,EAAE,aAAa;IAC5B,OAAO,EAAE,SAAS,EAAE,OAAO;IAC3B,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe;IACpF,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB;IACpD,SAAS;IACT,QAAQ,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc;IAClG,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY;IAC7F,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY;IAC5F,aAAa,EAAE,kBAAkB;IACjC,cAAc,EAAE,qBAAqB;IACrC,iBAAiB,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB;IACzG,OAAO;IACP,UAAU,EAAE,kBAAkB,EAAE,eAAe,EAAE,iBAAiB,EAAE,iBAAiB;IACrF,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe;IAClF,cAAc,EAAE,cAAc;IAC9B,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,KAAK;IACL,QAAQ,EAAE,UAAU,EAAE,qBAAqB,EAAE,aAAa,EAAE,QAAQ,EAAE,gBAAgB;IACtF,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU;IAC3F,MAAM,EAAE,cAAc,EAAE,YAAY,EA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AAC;AACf,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Go Concurrency Safety Security Checks
3
+ * OWASP A04:2025 - Insecure Design
4
+ *
5
+ * Detects concurrency-related vulnerabilities in Go code including race conditions
6
+ * and goroutine leaks.
7
+ */
8
+ import { SecurityVulnerability } from '../../types';
9
+ /**
10
+ * Checks for concurrency safety issues
11
+ *
12
+ * Covers:
13
+ * - Check #1: Race conditions (unsynchronized variable access in concurrent contexts) (HIGH)
14
+ * - Map access without mutex protection
15
+ * - Slice modifications without synchronization
16
+ * - Simple variable operations (counter++, assignments) without mutex/atomic
17
+ * - Check #2: Goroutine leaks (unclosed channels) (MEDIUM)
18
+ *
19
+ * @param lines - Array of code lines
20
+ * @returns Array of security vulnerabilities found
21
+ */
22
+ export declare function checkConcurrencySafety(lines: string[]): SecurityVulnerability[];
23
+ //# sourceMappingURL=concurrency-safety.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concurrency-safety.d.ts","sourceRoot":"","sources":["../../../../../../../../src/lib/analyzers/go/security-checks/concurrency-safety.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGpD;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,qBAAqB,EAAE,CA2V/E"}