@arsh342/athena 0.2.3 → 0.2.5
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/README.md +2 -1
- package/dist/index.cjs +921 -282
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -12058,13 +12058,13 @@ ${lanes.join("\n")}
|
|
|
12058
12058
|
writeOutputIsTTY() {
|
|
12059
12059
|
return process.stdout.isTTY;
|
|
12060
12060
|
},
|
|
12061
|
-
readFile:
|
|
12061
|
+
readFile: readFile6,
|
|
12062
12062
|
writeFile: writeFile22,
|
|
12063
12063
|
watchFile: watchFile2,
|
|
12064
12064
|
watchDirectory,
|
|
12065
12065
|
preferNonRecursiveWatch: !fsSupportsRecursiveFsWatch,
|
|
12066
12066
|
resolvePath: (path) => _path.resolve(path),
|
|
12067
|
-
fileExists,
|
|
12067
|
+
fileExists: fileExists2,
|
|
12068
12068
|
directoryExists,
|
|
12069
12069
|
getAccessibleFileSystemEntries,
|
|
12070
12070
|
createDirectory(directoryName) {
|
|
@@ -12099,9 +12099,9 @@ ${lanes.join("\n")}
|
|
|
12099
12099
|
return process.memoryUsage().heapUsed;
|
|
12100
12100
|
},
|
|
12101
12101
|
getFileSize(path) {
|
|
12102
|
-
const
|
|
12103
|
-
if (
|
|
12104
|
-
return
|
|
12102
|
+
const stat4 = statSync(path);
|
|
12103
|
+
if (stat4 == null ? void 0 : stat4.isFile()) {
|
|
12104
|
+
return stat4.size;
|
|
12105
12105
|
}
|
|
12106
12106
|
return 0;
|
|
12107
12107
|
},
|
|
@@ -12226,7 +12226,7 @@ ${lanes.join("\n")}
|
|
|
12226
12226
|
if (platform === "win32" || platform === "win64") {
|
|
12227
12227
|
return false;
|
|
12228
12228
|
}
|
|
12229
|
-
return !
|
|
12229
|
+
return !fileExists2(swapCase(__filename));
|
|
12230
12230
|
}
|
|
12231
12231
|
function swapCase(s) {
|
|
12232
12232
|
return s.replace(/\w/g, (ch) => {
|
|
@@ -12264,7 +12264,7 @@ ${lanes.join("\n")}
|
|
|
12264
12264
|
callback
|
|
12265
12265
|
);
|
|
12266
12266
|
}
|
|
12267
|
-
function
|
|
12267
|
+
function readFile6(fileName, _encoding) {
|
|
12268
12268
|
let buffer;
|
|
12269
12269
|
try {
|
|
12270
12270
|
buffer = _fs.readFileSync(fileName);
|
|
@@ -12319,19 +12319,19 @@ ${lanes.join("\n")}
|
|
|
12319
12319
|
if (entry === "." || entry === "..") {
|
|
12320
12320
|
continue;
|
|
12321
12321
|
}
|
|
12322
|
-
let
|
|
12322
|
+
let stat4;
|
|
12323
12323
|
if (typeof dirent === "string" || dirent.isSymbolicLink()) {
|
|
12324
12324
|
const name = combinePaths(path, entry);
|
|
12325
|
-
|
|
12326
|
-
if (!
|
|
12325
|
+
stat4 = statSync(name);
|
|
12326
|
+
if (!stat4) {
|
|
12327
12327
|
continue;
|
|
12328
12328
|
}
|
|
12329
12329
|
} else {
|
|
12330
|
-
|
|
12330
|
+
stat4 = dirent;
|
|
12331
12331
|
}
|
|
12332
|
-
if (
|
|
12332
|
+
if (stat4.isFile()) {
|
|
12333
12333
|
files.push(entry);
|
|
12334
|
-
} else if (
|
|
12334
|
+
} else if (stat4.isDirectory()) {
|
|
12335
12335
|
directories.push(entry);
|
|
12336
12336
|
}
|
|
12337
12337
|
}
|
|
@@ -12346,20 +12346,20 @@ ${lanes.join("\n")}
|
|
|
12346
12346
|
return matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames2, process.cwd(), depth, getAccessibleFileSystemEntries, realpath);
|
|
12347
12347
|
}
|
|
12348
12348
|
function fileSystemEntryExists(path, entryKind) {
|
|
12349
|
-
const
|
|
12350
|
-
if (!
|
|
12349
|
+
const stat4 = statSync(path);
|
|
12350
|
+
if (!stat4) {
|
|
12351
12351
|
return false;
|
|
12352
12352
|
}
|
|
12353
12353
|
switch (entryKind) {
|
|
12354
12354
|
case 0:
|
|
12355
|
-
return
|
|
12355
|
+
return stat4.isFile();
|
|
12356
12356
|
case 1:
|
|
12357
|
-
return
|
|
12357
|
+
return stat4.isDirectory();
|
|
12358
12358
|
default:
|
|
12359
12359
|
return false;
|
|
12360
12360
|
}
|
|
12361
12361
|
}
|
|
12362
|
-
function
|
|
12362
|
+
function fileExists2(path) {
|
|
12363
12363
|
return fileSystemEntryExists(
|
|
12364
12364
|
path,
|
|
12365
12365
|
0
|
|
@@ -48820,7 +48820,7 @@ ${lanes.join("\n")}
|
|
|
48820
48820
|
const possibleOption = getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName);
|
|
48821
48821
|
return possibleOption ? createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, node, diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, node, diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption);
|
|
48822
48822
|
}
|
|
48823
|
-
function parseCommandLineWorker(diagnostics, commandLine,
|
|
48823
|
+
function parseCommandLineWorker(diagnostics, commandLine, readFile6) {
|
|
48824
48824
|
const options = {};
|
|
48825
48825
|
let watchOptions;
|
|
48826
48826
|
const fileNames = [];
|
|
@@ -48868,7 +48868,7 @@ ${lanes.join("\n")}
|
|
|
48868
48868
|
}
|
|
48869
48869
|
}
|
|
48870
48870
|
function parseResponseFile(fileName) {
|
|
48871
|
-
const text = tryReadFile(fileName,
|
|
48871
|
+
const text = tryReadFile(fileName, readFile6 || ((fileName2) => sys.readFile(fileName2)));
|
|
48872
48872
|
if (!isString(text)) {
|
|
48873
48873
|
errors.push(text);
|
|
48874
48874
|
return;
|
|
@@ -48971,8 +48971,8 @@ ${lanes.join("\n")}
|
|
|
48971
48971
|
unknownDidYouMeanDiagnostic: Diagnostics.Unknown_compiler_option_0_Did_you_mean_1,
|
|
48972
48972
|
optionTypeMismatchDiagnostic: Diagnostics.Compiler_option_0_expects_an_argument
|
|
48973
48973
|
};
|
|
48974
|
-
function parseCommandLine(commandLine,
|
|
48975
|
-
return parseCommandLineWorker(compilerOptionsDidYouMeanDiagnostics, commandLine,
|
|
48974
|
+
function parseCommandLine(commandLine, readFile6) {
|
|
48975
|
+
return parseCommandLineWorker(compilerOptionsDidYouMeanDiagnostics, commandLine, readFile6);
|
|
48976
48976
|
}
|
|
48977
48977
|
function getOptionFromName(optionName, allowShort) {
|
|
48978
48978
|
return getOptionDeclarationFromName(getOptionsNameMap, optionName, allowShort);
|
|
@@ -49054,8 +49054,8 @@ ${lanes.join("\n")}
|
|
|
49054
49054
|
watchOptionsToExtend
|
|
49055
49055
|
);
|
|
49056
49056
|
}
|
|
49057
|
-
function readConfigFile(fileName,
|
|
49058
|
-
const textOrDiagnostic = tryReadFile(fileName,
|
|
49057
|
+
function readConfigFile(fileName, readFile6) {
|
|
49058
|
+
const textOrDiagnostic = tryReadFile(fileName, readFile6);
|
|
49059
49059
|
return isString(textOrDiagnostic) ? parseConfigFileTextToJson(fileName, textOrDiagnostic) : { config: {}, error: textOrDiagnostic };
|
|
49060
49060
|
}
|
|
49061
49061
|
function parseConfigFileTextToJson(fileName, jsonText) {
|
|
@@ -49070,14 +49070,14 @@ ${lanes.join("\n")}
|
|
|
49070
49070
|
error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : void 0
|
|
49071
49071
|
};
|
|
49072
49072
|
}
|
|
49073
|
-
function readJsonConfigFile(fileName,
|
|
49074
|
-
const textOrDiagnostic = tryReadFile(fileName,
|
|
49073
|
+
function readJsonConfigFile(fileName, readFile6) {
|
|
49074
|
+
const textOrDiagnostic = tryReadFile(fileName, readFile6);
|
|
49075
49075
|
return isString(textOrDiagnostic) ? parseJsonText(fileName, textOrDiagnostic) : { fileName, parseDiagnostics: [textOrDiagnostic] };
|
|
49076
49076
|
}
|
|
49077
|
-
function tryReadFile(fileName,
|
|
49077
|
+
function tryReadFile(fileName, readFile6) {
|
|
49078
49078
|
let text;
|
|
49079
49079
|
try {
|
|
49080
|
-
text =
|
|
49080
|
+
text = readFile6(fileName);
|
|
49081
49081
|
} catch (e) {
|
|
49082
49082
|
return createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message);
|
|
49083
49083
|
}
|
|
@@ -127174,7 +127174,7 @@ ${lanes.join("\n")}
|
|
|
127174
127174
|
}
|
|
127175
127175
|
}
|
|
127176
127176
|
function createImportCallExpressionAMD(arg, containsLexicalThis) {
|
|
127177
|
-
const
|
|
127177
|
+
const resolve10 = factory2.createUniqueName("resolve");
|
|
127178
127178
|
const reject = factory2.createUniqueName("reject");
|
|
127179
127179
|
const parameters = [
|
|
127180
127180
|
factory2.createParameterDeclaration(
|
|
@@ -127183,7 +127183,7 @@ ${lanes.join("\n")}
|
|
|
127183
127183
|
/*dotDotDotToken*/
|
|
127184
127184
|
void 0,
|
|
127185
127185
|
/*name*/
|
|
127186
|
-
|
|
127186
|
+
resolve10
|
|
127187
127187
|
),
|
|
127188
127188
|
factory2.createParameterDeclaration(
|
|
127189
127189
|
/*modifiers*/
|
|
@@ -127200,7 +127200,7 @@ ${lanes.join("\n")}
|
|
|
127200
127200
|
factory2.createIdentifier("require"),
|
|
127201
127201
|
/*typeArguments*/
|
|
127202
127202
|
void 0,
|
|
127203
|
-
[factory2.createArrayLiteralExpression([arg || factory2.createOmittedExpression()]),
|
|
127203
|
+
[factory2.createArrayLiteralExpression([arg || factory2.createOmittedExpression()]), resolve10, reject]
|
|
127204
127204
|
)
|
|
127205
127205
|
)
|
|
127206
127206
|
]);
|
|
@@ -138185,7 +138185,7 @@ ${lanes.join("\n")}
|
|
|
138185
138185
|
const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames2);
|
|
138186
138186
|
return {
|
|
138187
138187
|
useCaseSensitiveFileNames: useCaseSensitiveFileNames2,
|
|
138188
|
-
fileExists,
|
|
138188
|
+
fileExists: fileExists2,
|
|
138189
138189
|
readFile: (path, encoding) => host.readFile(path, encoding),
|
|
138190
138190
|
directoryExists: host.directoryExists && directoryExists,
|
|
138191
138191
|
getDirectories,
|
|
@@ -138271,7 +138271,7 @@ ${lanes.join("\n")}
|
|
|
138271
138271
|
}
|
|
138272
138272
|
return host.writeFile(fileName, data, writeByteOrderMark);
|
|
138273
138273
|
}
|
|
138274
|
-
function
|
|
138274
|
+
function fileExists2(fileName) {
|
|
138275
138275
|
const path = toPath3(fileName);
|
|
138276
138276
|
const result = getCachedFileSystemEntriesForBaseDir(path);
|
|
138277
138277
|
return result && hasEntry(result.sortedAndCanonicalizedFiles, getCanonicalFileName(getBaseNameOfFileName(fileName))) || host.fileExists(fileName);
|
|
@@ -138387,10 +138387,10 @@ ${lanes.join("\n")}
|
|
|
138387
138387
|
clearFirstAncestorEntry(filePath);
|
|
138388
138388
|
}
|
|
138389
138389
|
}
|
|
138390
|
-
function updateFilesOfFileSystemEntry(parentResult, baseName,
|
|
138390
|
+
function updateFilesOfFileSystemEntry(parentResult, baseName, fileExists22) {
|
|
138391
138391
|
const canonicalizedFiles = parentResult.sortedAndCanonicalizedFiles;
|
|
138392
138392
|
const canonicalizedBaseName = getCanonicalFileName(baseName);
|
|
138393
|
-
if (
|
|
138393
|
+
if (fileExists22) {
|
|
138394
138394
|
if (insertSorted(canonicalizedFiles, canonicalizedBaseName, compareStringsCaseSensitive)) {
|
|
138395
138395
|
parentResult.files.push(baseName);
|
|
138396
138396
|
}
|
|
@@ -138690,10 +138690,10 @@ ${lanes.join("\n")}
|
|
|
138690
138690
|
function closeFileWatcherOf(objWithWatcher) {
|
|
138691
138691
|
objWithWatcher.watcher.close();
|
|
138692
138692
|
}
|
|
138693
|
-
function findConfigFile(searchPath,
|
|
138693
|
+
function findConfigFile(searchPath, fileExists2, configName = "tsconfig.json") {
|
|
138694
138694
|
return forEachAncestorDirectory(searchPath, (ancestor) => {
|
|
138695
138695
|
const fileName = combinePaths(ancestor, configName);
|
|
138696
|
-
return
|
|
138696
|
+
return fileExists2(fileName) ? fileName : void 0;
|
|
138697
138697
|
});
|
|
138698
138698
|
}
|
|
138699
138699
|
function resolveTripleslashReference(moduleName, containingFile) {
|
|
@@ -138735,12 +138735,12 @@ ${lanes.join("\n")}
|
|
|
138735
138735
|
function createCompilerHost(options, setParentNodes) {
|
|
138736
138736
|
return createCompilerHostWorker(options, setParentNodes);
|
|
138737
138737
|
}
|
|
138738
|
-
function createGetSourceFile(
|
|
138738
|
+
function createGetSourceFile(readFile6, setParentNodes) {
|
|
138739
138739
|
return (fileName, languageVersionOrOptions, onError) => {
|
|
138740
138740
|
let text;
|
|
138741
138741
|
try {
|
|
138742
138742
|
mark("beforeIORead");
|
|
138743
|
-
text =
|
|
138743
|
+
text = readFile6(fileName);
|
|
138744
138744
|
mark("afterIORead");
|
|
138745
138745
|
measure("I/O Read", "beforeIORead", "afterIORead");
|
|
138746
138746
|
} catch (e) {
|
|
@@ -139300,14 +139300,14 @@ ${lanes.join("\n")}
|
|
|
139300
139300
|
}
|
|
139301
139301
|
return { file, pos, end, packageId };
|
|
139302
139302
|
}
|
|
139303
|
-
function isProgramUptoDate(program3, rootFileNames, newOptions, getSourceVersion,
|
|
139303
|
+
function isProgramUptoDate(program3, rootFileNames, newOptions, getSourceVersion, fileExists2, hasInvalidatedResolutions, hasInvalidatedLibResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) {
|
|
139304
139304
|
if (!program3 || (hasChangedAutomaticTypeDirectiveNames == null ? void 0 : hasChangedAutomaticTypeDirectiveNames())) return false;
|
|
139305
139305
|
if (!arrayIsEqualTo(program3.getRootFileNames(), rootFileNames)) return false;
|
|
139306
139306
|
let seenResolvedRefs;
|
|
139307
139307
|
if (!arrayIsEqualTo(program3.getProjectReferences(), projectReferences, projectReferenceUptoDate)) return false;
|
|
139308
139308
|
if (program3.getSourceFiles().some(sourceFileNotUptoDate)) return false;
|
|
139309
139309
|
const missingPaths = program3.getMissingFilePaths();
|
|
139310
|
-
if (missingPaths && forEachEntry(missingPaths,
|
|
139310
|
+
if (missingPaths && forEachEntry(missingPaths, fileExists2)) return false;
|
|
139311
139311
|
const currentOptions = program3.getCompilerOptions();
|
|
139312
139312
|
if (!compareDataObjects(currentOptions, newOptions)) return false;
|
|
139313
139313
|
if (program3.resolvedLibReferences && forEachEntry(program3.resolvedLibReferences, (_value, libFileName) => hasInvalidatedLibResolutions(libFileName))) return false;
|
|
@@ -139635,7 +139635,7 @@ ${lanes.join("\n")}
|
|
|
139635
139635
|
let mapSourceFileToResolvedRef;
|
|
139636
139636
|
let mapOutputFileToResolvedRef;
|
|
139637
139637
|
const useSourceOfProjectReferenceRedirect = !!((_d = host.useSourceOfProjectReferenceRedirect) == null ? void 0 : _d.call(host)) && !options.disableSourceOfProjectReferenceRedirect;
|
|
139638
|
-
const { onProgramCreateComplete, fileExists, directoryExists } = updateHostForUseSourceOfProjectReferenceRedirect({
|
|
139638
|
+
const { onProgramCreateComplete, fileExists: fileExists2, directoryExists } = updateHostForUseSourceOfProjectReferenceRedirect({
|
|
139639
139639
|
compilerHost: host,
|
|
139640
139640
|
getSymlinkCache,
|
|
139641
139641
|
useSourceOfProjectReferenceRedirect,
|
|
@@ -139644,7 +139644,7 @@ ${lanes.join("\n")}
|
|
|
139644
139644
|
getRedirectFromOutput,
|
|
139645
139645
|
forEachResolvedProjectReference: forEachResolvedProjectReference2
|
|
139646
139646
|
});
|
|
139647
|
-
const
|
|
139647
|
+
const readFile6 = host.readFile.bind(host);
|
|
139648
139648
|
(_e = tracing) == null ? void 0 : _e.push(tracing.Phase.Program, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
|
|
139649
139649
|
const shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
|
|
139650
139650
|
(_f = tracing) == null ? void 0 : _f.pop();
|
|
@@ -139869,8 +139869,8 @@ ${lanes.join("\n")}
|
|
|
139869
139869
|
getImpliedNodeFormatForEmit: getImpliedNodeFormatForEmit2,
|
|
139870
139870
|
shouldTransformImportCall,
|
|
139871
139871
|
emitBuildInfo,
|
|
139872
|
-
fileExists,
|
|
139873
|
-
readFile:
|
|
139872
|
+
fileExists: fileExists2,
|
|
139873
|
+
readFile: readFile6,
|
|
139874
139874
|
directoryExists,
|
|
139875
139875
|
getSymlinkCache,
|
|
139876
139876
|
realpath: (_o = host.realpath) == null ? void 0 : _o.bind(host),
|
|
@@ -140683,10 +140683,10 @@ ${lanes.join("\n")}
|
|
|
140683
140683
|
function getJSSyntacticDiagnosticsForFile(sourceFile) {
|
|
140684
140684
|
return runWithCancellationToken(() => {
|
|
140685
140685
|
const diagnostics = [];
|
|
140686
|
-
|
|
140687
|
-
forEachChildRecursively(sourceFile,
|
|
140686
|
+
walk3(sourceFile, sourceFile);
|
|
140687
|
+
forEachChildRecursively(sourceFile, walk3, walkArray);
|
|
140688
140688
|
return diagnostics;
|
|
140689
|
-
function
|
|
140689
|
+
function walk3(node, parent2) {
|
|
140690
140690
|
switch (parent2.kind) {
|
|
140691
140691
|
case 170:
|
|
140692
140692
|
case 173:
|
|
@@ -142368,8 +142368,8 @@ ${lanes.join("\n")}
|
|
|
142368
142368
|
const originalDirectoryExists = host.compilerHost.directoryExists;
|
|
142369
142369
|
const originalGetDirectories = host.compilerHost.getDirectories;
|
|
142370
142370
|
const originalRealpath = host.compilerHost.realpath;
|
|
142371
|
-
if (!host.useSourceOfProjectReferenceRedirect) return { onProgramCreateComplete: noop, fileExists };
|
|
142372
|
-
host.compilerHost.fileExists =
|
|
142371
|
+
if (!host.useSourceOfProjectReferenceRedirect) return { onProgramCreateComplete: noop, fileExists: fileExists2 };
|
|
142372
|
+
host.compilerHost.fileExists = fileExists2;
|
|
142373
142373
|
let directoryExists;
|
|
142374
142374
|
if (originalDirectoryExists) {
|
|
142375
142375
|
directoryExists = host.compilerHost.directoryExists = (path) => {
|
|
@@ -142408,13 +142408,13 @@ ${lanes.join("\n")}
|
|
|
142408
142408
|
return ((_a = host.getSymlinkCache().getSymlinkedFiles()) == null ? void 0 : _a.get(host.toPath(s))) || originalRealpath.call(host.compilerHost, s);
|
|
142409
142409
|
};
|
|
142410
142410
|
}
|
|
142411
|
-
return { onProgramCreateComplete, fileExists, directoryExists };
|
|
142411
|
+
return { onProgramCreateComplete, fileExists: fileExists2, directoryExists };
|
|
142412
142412
|
function onProgramCreateComplete() {
|
|
142413
142413
|
host.compilerHost.fileExists = originalFileExists;
|
|
142414
142414
|
host.compilerHost.directoryExists = originalDirectoryExists;
|
|
142415
142415
|
host.compilerHost.getDirectories = originalGetDirectories;
|
|
142416
142416
|
}
|
|
142417
|
-
function
|
|
142417
|
+
function fileExists2(file) {
|
|
142418
142418
|
if (originalFileExists.call(host.compilerHost, file)) return true;
|
|
142419
142419
|
if (!host.getResolvedProjectReferences()) return false;
|
|
142420
142420
|
if (!isDeclarationFileName(file)) return false;
|
|
@@ -146766,7 +146766,7 @@ ${lanes.join("\n")}
|
|
|
146766
146766
|
compilerHost.getSourceFile = (fileName, ...args) => getVersionedSourceFileByPath(fileName, toPath3(fileName), ...args);
|
|
146767
146767
|
compilerHost.getSourceFileByPath = getVersionedSourceFileByPath;
|
|
146768
146768
|
compilerHost.getNewLine = () => newLine;
|
|
146769
|
-
compilerHost.fileExists =
|
|
146769
|
+
compilerHost.fileExists = fileExists2;
|
|
146770
146770
|
compilerHost.onReleaseOldSourceFile = onReleaseOldSourceFile;
|
|
146771
146771
|
compilerHost.onReleaseParsedCommandLine = onReleaseParsedCommandLine;
|
|
146772
146772
|
compilerHost.toPath = toPath3;
|
|
@@ -146970,7 +146970,7 @@ ${lanes.join("\n")}
|
|
|
146970
146970
|
function isFilePresenceUnknownOnHost(hostSourceFile) {
|
|
146971
146971
|
return typeof hostSourceFile.version === "boolean";
|
|
146972
146972
|
}
|
|
146973
|
-
function
|
|
146973
|
+
function fileExists2(fileName) {
|
|
146974
146974
|
const path = toPath3(fileName);
|
|
146975
146975
|
if (isFileMissingOnHost(sourceFilesCache.get(path))) {
|
|
146976
146976
|
return false;
|
|
@@ -153939,15 +153939,15 @@ ${lanes.join("\n")}
|
|
|
153939
153939
|
}
|
|
153940
153940
|
return true;
|
|
153941
153941
|
}
|
|
153942
|
-
function getMappedLocation(location, sourceMapper,
|
|
153942
|
+
function getMappedLocation(location, sourceMapper, fileExists2) {
|
|
153943
153943
|
const mapsTo = sourceMapper.tryGetSourcePosition(location);
|
|
153944
|
-
return mapsTo && (!
|
|
153944
|
+
return mapsTo && (!fileExists2 || fileExists2(normalizePath(mapsTo.fileName)) ? mapsTo : void 0);
|
|
153945
153945
|
}
|
|
153946
|
-
function getMappedDocumentSpan(documentSpan, sourceMapper,
|
|
153946
|
+
function getMappedDocumentSpan(documentSpan, sourceMapper, fileExists2) {
|
|
153947
153947
|
const { fileName, textSpan } = documentSpan;
|
|
153948
|
-
const newPosition = getMappedLocation({ fileName, pos: textSpan.start }, sourceMapper,
|
|
153948
|
+
const newPosition = getMappedLocation({ fileName, pos: textSpan.start }, sourceMapper, fileExists2);
|
|
153949
153949
|
if (!newPosition) return void 0;
|
|
153950
|
-
const newEndPosition = getMappedLocation({ fileName, pos: textSpan.start + textSpan.length }, sourceMapper,
|
|
153950
|
+
const newEndPosition = getMappedLocation({ fileName, pos: textSpan.start + textSpan.length }, sourceMapper, fileExists2);
|
|
153951
153951
|
const newLength = newEndPosition ? newEndPosition.pos - newPosition.pos : textSpan.length;
|
|
153952
153952
|
return {
|
|
153953
153953
|
fileName: newPosition.fileName,
|
|
@@ -153957,20 +153957,20 @@ ${lanes.join("\n")}
|
|
|
153957
153957
|
},
|
|
153958
153958
|
originalFileName: documentSpan.fileName,
|
|
153959
153959
|
originalTextSpan: documentSpan.textSpan,
|
|
153960
|
-
contextSpan: getMappedContextSpan(documentSpan, sourceMapper,
|
|
153960
|
+
contextSpan: getMappedContextSpan(documentSpan, sourceMapper, fileExists2),
|
|
153961
153961
|
originalContextSpan: documentSpan.contextSpan
|
|
153962
153962
|
};
|
|
153963
153963
|
}
|
|
153964
|
-
function getMappedContextSpan(documentSpan, sourceMapper,
|
|
153964
|
+
function getMappedContextSpan(documentSpan, sourceMapper, fileExists2) {
|
|
153965
153965
|
const contextSpanStart = documentSpan.contextSpan && getMappedLocation(
|
|
153966
153966
|
{ fileName: documentSpan.fileName, pos: documentSpan.contextSpan.start },
|
|
153967
153967
|
sourceMapper,
|
|
153968
|
-
|
|
153968
|
+
fileExists2
|
|
153969
153969
|
);
|
|
153970
153970
|
const contextSpanEnd = documentSpan.contextSpan && getMappedLocation(
|
|
153971
153971
|
{ fileName: documentSpan.fileName, pos: documentSpan.contextSpan.start + documentSpan.contextSpan.length },
|
|
153972
153972
|
sourceMapper,
|
|
153973
|
-
|
|
153973
|
+
fileExists2
|
|
153974
153974
|
);
|
|
153975
153975
|
return contextSpanStart && contextSpanEnd ? { start: contextSpanStart.pos, length: contextSpanEnd.pos - contextSpanStart.pos } : void 0;
|
|
153976
153976
|
}
|
|
@@ -167632,7 +167632,7 @@ ${newComment.split("\n").map((c3) => ` * ${c3}`).join("\n")}
|
|
|
167632
167632
|
}
|
|
167633
167633
|
function initializeNameTable(sourceFile) {
|
|
167634
167634
|
const nameTable = sourceFile.nameTable = /* @__PURE__ */ new Map();
|
|
167635
|
-
sourceFile.forEachChild(function
|
|
167635
|
+
sourceFile.forEachChild(function walk3(node) {
|
|
167636
167636
|
if (isIdentifier(node) && !isTagName(node) && node.escapedText || isStringOrNumericLiteralLike(node) && literalIsName(node)) {
|
|
167637
167637
|
const text = getEscapedTextOfIdentifierOrLiteral(node);
|
|
167638
167638
|
nameTable.set(text, nameTable.get(text) === void 0 ? node.pos : -1);
|
|
@@ -167640,10 +167640,10 @@ ${newComment.split("\n").map((c3) => ` * ${c3}`).join("\n")}
|
|
|
167640
167640
|
const text = node.escapedText;
|
|
167641
167641
|
nameTable.set(text, nameTable.get(text) === void 0 ? node.pos : -1);
|
|
167642
167642
|
}
|
|
167643
|
-
forEachChild(node,
|
|
167643
|
+
forEachChild(node, walk3);
|
|
167644
167644
|
if (hasJSDocNodes(node)) {
|
|
167645
167645
|
for (const jsDoc of node.jsDoc) {
|
|
167646
|
-
forEachChild(jsDoc,
|
|
167646
|
+
forEachChild(jsDoc, walk3);
|
|
167647
167647
|
}
|
|
167648
167648
|
}
|
|
167649
167649
|
});
|
|
@@ -202454,9 +202454,9 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
202454
202454
|
this.markContainingProjectsAsDirty();
|
|
202455
202455
|
}
|
|
202456
202456
|
}
|
|
202457
|
-
close(
|
|
202457
|
+
close(fileExists2 = true) {
|
|
202458
202458
|
this.textStorage.isOpen = false;
|
|
202459
|
-
if (
|
|
202459
|
+
if (fileExists2 && this.textStorage.scheduleReloadIfNeeded()) {
|
|
202460
202460
|
this.markContainingProjectsAsDirty();
|
|
202461
202461
|
}
|
|
202462
202462
|
}
|
|
@@ -203560,11 +203560,11 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
203560
203560
|
this.rootFilesMap.set(path, { fileName });
|
|
203561
203561
|
this.markAsDirty();
|
|
203562
203562
|
}
|
|
203563
|
-
removeFile(info,
|
|
203563
|
+
removeFile(info, fileExists2, detachFromProject) {
|
|
203564
203564
|
if (this.isRoot(info)) {
|
|
203565
203565
|
this.removeRoot(info);
|
|
203566
203566
|
}
|
|
203567
|
-
if (
|
|
203567
|
+
if (fileExists2) {
|
|
203568
203568
|
this.resolutionCache.removeResolutionsOfFile(info.path);
|
|
203569
203569
|
} else {
|
|
203570
203570
|
this.resolutionCache.invalidateResolutionOfFile(info.path);
|
|
@@ -206434,8 +206434,8 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
206434
206434
|
*/
|
|
206435
206435
|
closeOpenFile(info, skipAssignOrphanScriptInfosToInferredProject) {
|
|
206436
206436
|
var _a;
|
|
206437
|
-
const
|
|
206438
|
-
info.close(
|
|
206437
|
+
const fileExists2 = info.isDynamic ? false : this.host.fileExists(info.fileName);
|
|
206438
|
+
info.close(fileExists2);
|
|
206439
206439
|
this.stopWatchingConfigFilesForScriptInfo(info);
|
|
206440
206440
|
const canonicalFileName = this.toCanonicalFileName(info.fileName);
|
|
206441
206441
|
if (this.openFilesWithNonRootedDiskPath.get(canonicalFileName) === info) {
|
|
@@ -206461,7 +206461,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
206461
206461
|
}
|
|
206462
206462
|
p.removeFile(
|
|
206463
206463
|
info,
|
|
206464
|
-
|
|
206464
|
+
fileExists2,
|
|
206465
206465
|
/*detachFromProject*/
|
|
206466
206466
|
true
|
|
206467
206467
|
);
|
|
@@ -206477,7 +206477,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
206477
206477
|
if (!skipAssignOrphanScriptInfosToInferredProject && ensureProjectsForOpenFiles) {
|
|
206478
206478
|
this.assignOrphanScriptInfosToInferredProject();
|
|
206479
206479
|
}
|
|
206480
|
-
if (
|
|
206480
|
+
if (fileExists2) {
|
|
206481
206481
|
this.watchClosedScriptInfo(info);
|
|
206482
206482
|
} else {
|
|
206483
206483
|
this.handleDeletedFile(
|
|
@@ -213918,8 +213918,8 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
|
|
|
213918
213918
|
installPackage(options) {
|
|
213919
213919
|
this.packageInstallId++;
|
|
213920
213920
|
const request = { kind: "installPackage", ...options, id: this.packageInstallId };
|
|
213921
|
-
const promise = new Promise((
|
|
213922
|
-
(this.packageInstalledPromise ?? (this.packageInstalledPromise = /* @__PURE__ */ new Map())).set(this.packageInstallId, { resolve:
|
|
213921
|
+
const promise = new Promise((resolve10, reject) => {
|
|
213922
|
+
(this.packageInstalledPromise ?? (this.packageInstalledPromise = /* @__PURE__ */ new Map())).set(this.packageInstallId, { resolve: resolve10, reject });
|
|
213923
213923
|
});
|
|
213924
213924
|
this.installer.send(request);
|
|
213925
213925
|
return promise;
|
|
@@ -214264,6 +214264,17 @@ var defaultConfig = {
|
|
|
214264
214264
|
timeoutMs: 6e4,
|
|
214265
214265
|
reportType: "security"
|
|
214266
214266
|
},
|
|
214267
|
+
trivy: {
|
|
214268
|
+
enabled: true,
|
|
214269
|
+
timeoutMs: 12e4,
|
|
214270
|
+
scanners: ["vuln", "misconfig", "secret"],
|
|
214271
|
+
severities: ["HIGH", "CRITICAL"]
|
|
214272
|
+
},
|
|
214273
|
+
horusec: {
|
|
214274
|
+
enabled: true,
|
|
214275
|
+
timeoutMs: 18e4,
|
|
214276
|
+
disableDocker: false
|
|
214277
|
+
},
|
|
214267
214278
|
maxFileSize: 1048576,
|
|
214268
214279
|
weights: defaultWeights
|
|
214269
214280
|
};
|
|
@@ -214297,6 +214308,17 @@ function mergeConfig(config = {}) {
|
|
|
214297
214308
|
timeoutMs: config.bearer?.timeoutMs ?? defaultConfig.bearer.timeoutMs,
|
|
214298
214309
|
reportType: config.bearer?.reportType ?? defaultConfig.bearer.reportType
|
|
214299
214310
|
},
|
|
214311
|
+
trivy: {
|
|
214312
|
+
enabled: config.trivy?.enabled ?? defaultConfig.trivy.enabled,
|
|
214313
|
+
timeoutMs: config.trivy?.timeoutMs ?? defaultConfig.trivy.timeoutMs,
|
|
214314
|
+
scanners: config.trivy?.scanners ?? defaultConfig.trivy.scanners,
|
|
214315
|
+
severities: config.trivy?.severities ?? defaultConfig.trivy.severities
|
|
214316
|
+
},
|
|
214317
|
+
horusec: {
|
|
214318
|
+
enabled: config.horusec?.enabled ?? defaultConfig.horusec.enabled,
|
|
214319
|
+
timeoutMs: config.horusec?.timeoutMs ?? defaultConfig.horusec.timeoutMs,
|
|
214320
|
+
disableDocker: config.horusec?.disableDocker ?? defaultConfig.horusec.disableDocker
|
|
214321
|
+
},
|
|
214300
214322
|
weights: {
|
|
214301
214323
|
...defaultWeights,
|
|
214302
214324
|
...config.weights
|
|
@@ -214305,7 +214327,7 @@ function mergeConfig(config = {}) {
|
|
|
214305
214327
|
}
|
|
214306
214328
|
|
|
214307
214329
|
// ../core/dist/engine.js
|
|
214308
|
-
var
|
|
214330
|
+
var import_promises4 = require("fs/promises");
|
|
214309
214331
|
|
|
214310
214332
|
// ../core/dist/analyzers/hallucination-detector.js
|
|
214311
214333
|
var import_node_crypto = require("crypto");
|
|
@@ -214565,6 +214587,7 @@ function generateReport(startedAt, files, totalLoc, skippedFiles, config) {
|
|
|
214565
214587
|
const units = files.flatMap((file) => file.units);
|
|
214566
214588
|
const findings = files.flatMap((file) => file.findings);
|
|
214567
214589
|
const severityCounts = severityOrder.reduce((acc, severity) => ({ ...acc, [severity]: findings.filter((finding) => finding.severity === severity).length }), { CRITICAL: 0, HIGH: 0, MEDIUM: 0, LOW: 0 });
|
|
214590
|
+
const sourceBreakdown = summarizeSourceBreakdown(findings);
|
|
214568
214591
|
const confidenceBands = {
|
|
214569
214592
|
LOW: countBand(units, "LOW"),
|
|
214570
214593
|
UNCERTAIN: countBand(units, "UNCERTAIN"),
|
|
@@ -214605,7 +214628,8 @@ function generateReport(startedAt, files, totalLoc, skippedFiles, config) {
|
|
|
214605
214628
|
security: {
|
|
214606
214629
|
findings: severityCounts,
|
|
214607
214630
|
blocked,
|
|
214608
|
-
riskDensity
|
|
214631
|
+
riskDensity,
|
|
214632
|
+
sourceBreakdown
|
|
214609
214633
|
},
|
|
214610
214634
|
weightedContributions,
|
|
214611
214635
|
calibration: {
|
|
@@ -214640,6 +214664,30 @@ function summarizeWeightedContributions(units) {
|
|
|
214640
214664
|
maxWeight: values.maxWeight
|
|
214641
214665
|
})).sort((a, b) => b.score - a.score).slice(0, 8);
|
|
214642
214666
|
}
|
|
214667
|
+
function summarizeSourceBreakdown(findings) {
|
|
214668
|
+
const createBucket = () => ({
|
|
214669
|
+
total: 0,
|
|
214670
|
+
findings: { CRITICAL: 0, HIGH: 0, MEDIUM: 0, LOW: 0 },
|
|
214671
|
+
bySource: {}
|
|
214672
|
+
});
|
|
214673
|
+
const buckets = {
|
|
214674
|
+
local: createBucket(),
|
|
214675
|
+
external: createBucket()
|
|
214676
|
+
};
|
|
214677
|
+
for (const finding of findings) {
|
|
214678
|
+
const pass = classifyFindingPass(finding.source);
|
|
214679
|
+
buckets[pass].total += 1;
|
|
214680
|
+
buckets[pass].findings[finding.severity] += 1;
|
|
214681
|
+
buckets[pass].bySource[finding.source] = (buckets[pass].bySource[finding.source] ?? 0) + 1;
|
|
214682
|
+
}
|
|
214683
|
+
return buckets;
|
|
214684
|
+
}
|
|
214685
|
+
function classifyFindingPass(source) {
|
|
214686
|
+
if (source === "secret-detector" || source === "hallucination-detector" || source === "security-analyzer") {
|
|
214687
|
+
return "local";
|
|
214688
|
+
}
|
|
214689
|
+
return "external";
|
|
214690
|
+
}
|
|
214643
214691
|
function formatJsonl(report) {
|
|
214644
214692
|
return report.files.flatMap((file) => file.findings).map((finding) => JSON.stringify(finding)).join("\n");
|
|
214645
214693
|
}
|
|
@@ -215633,6 +215681,366 @@ function getBearerCategory(category, dataTypes) {
|
|
|
215633
215681
|
return lowerCategory.replace(/\s+/g, "-");
|
|
215634
215682
|
}
|
|
215635
215683
|
|
|
215684
|
+
// ../core/dist/analyzers/trivy-adapter.js
|
|
215685
|
+
var import_node_crypto9 = require("crypto");
|
|
215686
|
+
var import_node_child_process6 = require("child_process");
|
|
215687
|
+
var import_node_util6 = require("util");
|
|
215688
|
+
var import_node_path6 = require("path");
|
|
215689
|
+
var execFileAsync6 = (0, import_node_util6.promisify)(import_node_child_process6.execFile);
|
|
215690
|
+
async function runTrivy(projectRoot, config) {
|
|
215691
|
+
if (!config.enabled)
|
|
215692
|
+
return [];
|
|
215693
|
+
const scanners = (config.scanners?.length ? config.scanners : ["vuln", "misconfig", "secret"]).join(",");
|
|
215694
|
+
const severities = (config.severities?.length ? config.severities : ["HIGH", "CRITICAL"]).join(",");
|
|
215695
|
+
try {
|
|
215696
|
+
const output = await execTrivy([
|
|
215697
|
+
"fs",
|
|
215698
|
+
"--format",
|
|
215699
|
+
"json",
|
|
215700
|
+
"--quiet",
|
|
215701
|
+
"--scanners",
|
|
215702
|
+
scanners,
|
|
215703
|
+
"--severity",
|
|
215704
|
+
severities,
|
|
215705
|
+
projectRoot
|
|
215706
|
+
], config.timeoutMs);
|
|
215707
|
+
if (!output)
|
|
215708
|
+
return [];
|
|
215709
|
+
return normalizeTrivyReport(safeParseTrivy(output), projectRoot);
|
|
215710
|
+
} catch (error) {
|
|
215711
|
+
const withStreams = error;
|
|
215712
|
+
if (withStreams?.code === "ENOENT") {
|
|
215713
|
+
console.warn("[athena-core] Trivy not installed; skipping Trivy scan. Install from https://trivy.dev/latest/getting-started/installation/");
|
|
215714
|
+
return [];
|
|
215715
|
+
}
|
|
215716
|
+
const detail = withStreams?.stderr?.trim() || withStreams?.message || String(error);
|
|
215717
|
+
console.warn(`[athena-core] Trivy execution failed: ${detail}`);
|
|
215718
|
+
return [];
|
|
215719
|
+
}
|
|
215720
|
+
}
|
|
215721
|
+
async function execTrivy(args, timeoutMs) {
|
|
215722
|
+
try {
|
|
215723
|
+
const { stdout } = await execFileAsync6("trivy", args, {
|
|
215724
|
+
timeout: timeoutMs,
|
|
215725
|
+
maxBuffer: 20 * 1024 * 1024
|
|
215726
|
+
});
|
|
215727
|
+
return stdout;
|
|
215728
|
+
} catch (error) {
|
|
215729
|
+
const withStreams = error;
|
|
215730
|
+
if (withStreams?.stdout && withStreams.stdout.trim().startsWith("{")) {
|
|
215731
|
+
return withStreams.stdout;
|
|
215732
|
+
}
|
|
215733
|
+
if (withStreams?.code === "ENOENT") {
|
|
215734
|
+
console.warn("[athena-core] Trivy not installed; skipping Trivy scan");
|
|
215735
|
+
return null;
|
|
215736
|
+
}
|
|
215737
|
+
const detail = withStreams?.stderr?.trim() || withStreams?.message || String(error);
|
|
215738
|
+
console.warn(`[athena-core] Trivy execution failed: ${detail}`);
|
|
215739
|
+
return null;
|
|
215740
|
+
}
|
|
215741
|
+
}
|
|
215742
|
+
function safeParseTrivy(json) {
|
|
215743
|
+
try {
|
|
215744
|
+
return JSON.parse(json);
|
|
215745
|
+
} catch {
|
|
215746
|
+
return { Results: [] };
|
|
215747
|
+
}
|
|
215748
|
+
}
|
|
215749
|
+
function normalizeTrivyReport(report, projectRoot) {
|
|
215750
|
+
return (report.Results ?? []).flatMap((result) => {
|
|
215751
|
+
const file = resolveTrivyTarget(projectRoot, result.Target);
|
|
215752
|
+
return [
|
|
215753
|
+
...(result.Vulnerabilities ?? []).map((finding) => normalizeTrivyVulnerability(finding, file)),
|
|
215754
|
+
...(result.Misconfigurations ?? []).map((finding) => normalizeTrivyMisconfiguration(finding, file)),
|
|
215755
|
+
...(result.Secrets ?? []).map((finding) => normalizeTrivySecret(finding, file))
|
|
215756
|
+
];
|
|
215757
|
+
});
|
|
215758
|
+
}
|
|
215759
|
+
function resolveTrivyTarget(projectRoot, target) {
|
|
215760
|
+
if (!target || target.trim().length === 0)
|
|
215761
|
+
return (0, import_node_path6.resolve)(projectRoot, "package.json");
|
|
215762
|
+
return (0, import_node_path6.resolve)(projectRoot, target);
|
|
215763
|
+
}
|
|
215764
|
+
function normalizeTrivyVulnerability(finding, file) {
|
|
215765
|
+
const vulnId = finding.VulnerabilityID?.trim() || "trivy-vuln";
|
|
215766
|
+
const pkg = finding.PkgName?.trim() || "dependency";
|
|
215767
|
+
const fixed = finding.FixedVersion?.trim() ? `; fixed=${finding.FixedVersion.trim()}` : "";
|
|
215768
|
+
const installed = finding.InstalledVersion?.trim() ? ` installed=${finding.InstalledVersion.trim()}` : "";
|
|
215769
|
+
const title = finding.Title?.trim() || finding.Description?.trim() || `Vulnerability in ${pkg}`;
|
|
215770
|
+
return {
|
|
215771
|
+
id: (0, import_node_crypto9.createHash)("sha1").update(`trivy:vuln:${file}:${vulnId}:${pkg}`).digest("hex").slice(0, 10),
|
|
215772
|
+
ruleId: `trivy:${vulnId}`,
|
|
215773
|
+
file,
|
|
215774
|
+
line: 1,
|
|
215775
|
+
column: 1,
|
|
215776
|
+
code: `${pkg}${installed}`.trim(),
|
|
215777
|
+
type: "Trivy Vulnerability",
|
|
215778
|
+
message: `${title} (${pkg}${fixed})`,
|
|
215779
|
+
category: "supply-chain-security",
|
|
215780
|
+
severity: mapTrivySeverity(finding.Severity)
|
|
215781
|
+
};
|
|
215782
|
+
}
|
|
215783
|
+
function normalizeTrivyMisconfiguration(finding, file) {
|
|
215784
|
+
const ruleId = finding.ID?.trim() || finding.AVDID?.trim() || "trivy-misconfig";
|
|
215785
|
+
const line = finding.CauseMetadata?.StartLine || 1;
|
|
215786
|
+
const code = finding.CauseMetadata?.Code?.Lines?.map((entry) => entry.Content?.trim() || "").filter(Boolean).join("\n") || "";
|
|
215787
|
+
const title = finding.Title?.trim() || finding.Message?.trim() || finding.Description?.trim() || "Misconfiguration";
|
|
215788
|
+
const resolution = finding.Resolution?.trim() ? ` Resolution: ${finding.Resolution.trim()}` : "";
|
|
215789
|
+
return {
|
|
215790
|
+
id: (0, import_node_crypto9.createHash)("sha1").update(`trivy:misconfig:${file}:${line}:${ruleId}`).digest("hex").slice(0, 10),
|
|
215791
|
+
ruleId: `trivy:${ruleId}`,
|
|
215792
|
+
file,
|
|
215793
|
+
line,
|
|
215794
|
+
column: 1,
|
|
215795
|
+
code,
|
|
215796
|
+
type: "Trivy Misconfiguration",
|
|
215797
|
+
message: `${title}.${resolution}`.trim(),
|
|
215798
|
+
category: "misconfiguration",
|
|
215799
|
+
severity: mapTrivySeverity(finding.Severity)
|
|
215800
|
+
};
|
|
215801
|
+
}
|
|
215802
|
+
function normalizeTrivySecret(finding, file) {
|
|
215803
|
+
const ruleId = finding.RuleID?.trim() || "trivy-secret";
|
|
215804
|
+
const line = finding.StartLine || 1;
|
|
215805
|
+
const title = finding.Title?.trim() || finding.Category?.trim() || "Hardcoded secret";
|
|
215806
|
+
return {
|
|
215807
|
+
id: (0, import_node_crypto9.createHash)("sha1").update(`trivy:secret:${file}:${line}:${ruleId}`).digest("hex").slice(0, 10),
|
|
215808
|
+
ruleId: `trivy:${ruleId}`,
|
|
215809
|
+
file,
|
|
215810
|
+
line,
|
|
215811
|
+
column: 1,
|
|
215812
|
+
code: finding.Match?.trim() || "",
|
|
215813
|
+
type: "Trivy Secret",
|
|
215814
|
+
message: title,
|
|
215815
|
+
category: "secret-exposure",
|
|
215816
|
+
severity: mapTrivySeverity(finding.Severity)
|
|
215817
|
+
};
|
|
215818
|
+
}
|
|
215819
|
+
function mapTrivySeverity(severity) {
|
|
215820
|
+
const value = (severity || "").toLowerCase();
|
|
215821
|
+
if (value === "critical")
|
|
215822
|
+
return "CRITICAL";
|
|
215823
|
+
if (value === "high")
|
|
215824
|
+
return "HIGH";
|
|
215825
|
+
if (value === "medium")
|
|
215826
|
+
return "MEDIUM";
|
|
215827
|
+
return "LOW";
|
|
215828
|
+
}
|
|
215829
|
+
|
|
215830
|
+
// ../core/dist/analyzers/horusec-adapter.js
|
|
215831
|
+
var import_node_crypto10 = require("crypto");
|
|
215832
|
+
var import_node_child_process7 = require("child_process");
|
|
215833
|
+
var import_promises3 = require("fs/promises");
|
|
215834
|
+
var import_node_os = require("os");
|
|
215835
|
+
var import_node_path7 = require("path");
|
|
215836
|
+
var import_node_util7 = require("util");
|
|
215837
|
+
var execFileAsync7 = (0, import_node_util7.promisify)(import_node_child_process7.execFile);
|
|
215838
|
+
async function runHorusec(projectRoot, config) {
|
|
215839
|
+
if (!config.enabled)
|
|
215840
|
+
return [];
|
|
215841
|
+
const tempDir = await (0, import_promises3.mkdtemp)((0, import_node_path7.join)((0, import_node_os.tmpdir)(), "athena-horusec-"));
|
|
215842
|
+
const reportPath = (0, import_node_path7.join)(tempDir, "horusec-report.json");
|
|
215843
|
+
const shouldDisableDocker = config.disableDocker || !await checkDockerAvailable2();
|
|
215844
|
+
if (shouldDisableDocker) {
|
|
215845
|
+
console.warn("[athena-core] Horusec running with Docker disabled (-D true). Analysis coverage may be reduced.");
|
|
215846
|
+
}
|
|
215847
|
+
try {
|
|
215848
|
+
const output = await execHorusec(projectRoot, reportPath, config.timeoutMs, shouldDisableDocker);
|
|
215849
|
+
const reportText = await readHorusecReport(reportPath, output);
|
|
215850
|
+
if (!reportText)
|
|
215851
|
+
return [];
|
|
215852
|
+
const parsed2 = safeParseHorusec(reportText);
|
|
215853
|
+
return collectHorusecFindings(parsed2, projectRoot);
|
|
215854
|
+
} catch (error) {
|
|
215855
|
+
const withStreams = error;
|
|
215856
|
+
if (withStreams?.code === "ENOENT") {
|
|
215857
|
+
console.warn("[athena-core] Horusec not installed; skipping Horusec scan.");
|
|
215858
|
+
return [];
|
|
215859
|
+
}
|
|
215860
|
+
const detail = withStreams?.stderr?.trim() || withStreams?.message || String(error);
|
|
215861
|
+
console.warn(`[athena-core] Horusec execution failed: ${detail}`);
|
|
215862
|
+
return [];
|
|
215863
|
+
} finally {
|
|
215864
|
+
await (0, import_promises3.rm)(reportPath, { force: true }).catch(() => {
|
|
215865
|
+
});
|
|
215866
|
+
await (0, import_promises3.rm)(tempDir, { recursive: true, force: true }).catch(() => {
|
|
215867
|
+
});
|
|
215868
|
+
await (0, import_promises3.rm)((0, import_node_path7.join)(projectRoot, ".horusec"), { recursive: true, force: true }).catch(() => {
|
|
215869
|
+
});
|
|
215870
|
+
}
|
|
215871
|
+
}
|
|
215872
|
+
async function execHorusec(projectRoot, reportPath, timeoutMs, disableDocker) {
|
|
215873
|
+
const baseArgs = ["start", "-p", projectRoot];
|
|
215874
|
+
if (disableDocker)
|
|
215875
|
+
baseArgs.push("-D", "true");
|
|
215876
|
+
const attempts = [
|
|
215877
|
+
[...baseArgs, "-o", "json", "-O", reportPath],
|
|
215878
|
+
[...baseArgs, "--output-format", "json", "--json-output-file", reportPath]
|
|
215879
|
+
];
|
|
215880
|
+
let lastError = null;
|
|
215881
|
+
for (const args of attempts) {
|
|
215882
|
+
try {
|
|
215883
|
+
const { stdout } = await execFileAsync7("horusec", args, {
|
|
215884
|
+
timeout: timeoutMs,
|
|
215885
|
+
maxBuffer: 20 * 1024 * 1024
|
|
215886
|
+
});
|
|
215887
|
+
return stdout;
|
|
215888
|
+
} catch (error) {
|
|
215889
|
+
lastError = error;
|
|
215890
|
+
const withStreams = error;
|
|
215891
|
+
if (await fileExists(reportPath)) {
|
|
215892
|
+
return withStreams?.stdout || null;
|
|
215893
|
+
}
|
|
215894
|
+
if (withStreams?.code === "ENOENT") {
|
|
215895
|
+
throw error;
|
|
215896
|
+
}
|
|
215897
|
+
}
|
|
215898
|
+
}
|
|
215899
|
+
throw lastError instanceof Error ? lastError : new Error("Horusec execution failed");
|
|
215900
|
+
}
|
|
215901
|
+
async function readHorusecReport(reportPath, stdout) {
|
|
215902
|
+
if (await fileExists(reportPath)) {
|
|
215903
|
+
return (0, import_promises3.readFile)(reportPath, "utf8");
|
|
215904
|
+
}
|
|
215905
|
+
if (stdout && stdout.trim().startsWith("{")) {
|
|
215906
|
+
return stdout;
|
|
215907
|
+
}
|
|
215908
|
+
return null;
|
|
215909
|
+
}
|
|
215910
|
+
async function checkDockerAvailable2() {
|
|
215911
|
+
try {
|
|
215912
|
+
await execFileAsync7("docker", ["--version"], { timeout: 5e3 });
|
|
215913
|
+
return true;
|
|
215914
|
+
} catch {
|
|
215915
|
+
return false;
|
|
215916
|
+
}
|
|
215917
|
+
}
|
|
215918
|
+
async function fileExists(path) {
|
|
215919
|
+
try {
|
|
215920
|
+
await (0, import_promises3.stat)(path);
|
|
215921
|
+
return true;
|
|
215922
|
+
} catch {
|
|
215923
|
+
return false;
|
|
215924
|
+
}
|
|
215925
|
+
}
|
|
215926
|
+
function safeParseHorusec(json) {
|
|
215927
|
+
try {
|
|
215928
|
+
return JSON.parse(json);
|
|
215929
|
+
} catch {
|
|
215930
|
+
return {};
|
|
215931
|
+
}
|
|
215932
|
+
}
|
|
215933
|
+
function collectHorusecFindings(root, projectRoot) {
|
|
215934
|
+
const findings = [];
|
|
215935
|
+
const seen = /* @__PURE__ */ new Set();
|
|
215936
|
+
walk(root, (value) => {
|
|
215937
|
+
const normalized = normalizeHorusecFinding(value, projectRoot);
|
|
215938
|
+
if (!normalized)
|
|
215939
|
+
return;
|
|
215940
|
+
if (seen.has(normalized.id))
|
|
215941
|
+
return;
|
|
215942
|
+
seen.add(normalized.id);
|
|
215943
|
+
findings.push(normalized);
|
|
215944
|
+
});
|
|
215945
|
+
return findings;
|
|
215946
|
+
}
|
|
215947
|
+
function walk(value, onObject) {
|
|
215948
|
+
if (Array.isArray(value)) {
|
|
215949
|
+
for (const entry of value)
|
|
215950
|
+
walk(entry, onObject);
|
|
215951
|
+
return;
|
|
215952
|
+
}
|
|
215953
|
+
if (!value || typeof value !== "object")
|
|
215954
|
+
return;
|
|
215955
|
+
onObject(value);
|
|
215956
|
+
for (const child of Object.values(value))
|
|
215957
|
+
walk(child, onObject);
|
|
215958
|
+
}
|
|
215959
|
+
function normalizeHorusecFinding(value, projectRoot) {
|
|
215960
|
+
const fileRaw = readString(value, ["file", "filename", "path"]);
|
|
215961
|
+
const details = readString(value, ["details", "description", "message"]);
|
|
215962
|
+
const severityRaw = readString(value, ["severity", "risk"]);
|
|
215963
|
+
if (!fileRaw || !details || !severityRaw)
|
|
215964
|
+
return null;
|
|
215965
|
+
const line = readNumber(value, ["line", "lineNumber"]) || 1;
|
|
215966
|
+
const column = readNumber(value, ["column", "col"]) || 1;
|
|
215967
|
+
const code = readString(value, ["code", "content"]) || "";
|
|
215968
|
+
const ruleId = readString(value, ["ruleID", "ruleId", "rule_id"]) || "horusec.unknown-rule";
|
|
215969
|
+
const securityTool = readString(value, ["securityTool", "tool"]) || "Horusec";
|
|
215970
|
+
const typeLabel = readString(value, ["type"]) || "Vulnerability";
|
|
215971
|
+
const category = deriveCategory(ruleId, securityTool, details);
|
|
215972
|
+
const file = (0, import_node_path7.resolve)(projectRoot, normalizeRelativeFile(fileRaw, projectRoot));
|
|
215973
|
+
const severity = mapHorusecSeverity(severityRaw);
|
|
215974
|
+
return {
|
|
215975
|
+
id: (0, import_node_crypto10.createHash)("sha1").update(`horusec:${file}:${line}:${column}:${ruleId}:${details}`).digest("hex").slice(0, 10),
|
|
215976
|
+
ruleId: `horusec:${ruleId}`,
|
|
215977
|
+
file,
|
|
215978
|
+
line,
|
|
215979
|
+
column,
|
|
215980
|
+
code,
|
|
215981
|
+
type: `${securityTool} ${typeLabel}`.trim(),
|
|
215982
|
+
message: details,
|
|
215983
|
+
category,
|
|
215984
|
+
severity
|
|
215985
|
+
};
|
|
215986
|
+
}
|
|
215987
|
+
function normalizeRelativeFile(file, projectRoot) {
|
|
215988
|
+
const normalizedRoot = (0, import_node_path7.resolve)(projectRoot);
|
|
215989
|
+
const normalizedFile = (0, import_node_path7.resolve)(file);
|
|
215990
|
+
if (normalizedFile.startsWith(normalizedRoot))
|
|
215991
|
+
return normalizedFile;
|
|
215992
|
+
return file;
|
|
215993
|
+
}
|
|
215994
|
+
function readString(value, keys) {
|
|
215995
|
+
for (const key of keys) {
|
|
215996
|
+
const candidate = value[key];
|
|
215997
|
+
if (typeof candidate === "string" && candidate.trim().length > 0)
|
|
215998
|
+
return candidate.trim();
|
|
215999
|
+
}
|
|
216000
|
+
return null;
|
|
216001
|
+
}
|
|
216002
|
+
function readNumber(value, keys) {
|
|
216003
|
+
for (const key of keys) {
|
|
216004
|
+
const candidate = value[key];
|
|
216005
|
+
if (typeof candidate === "number" && Number.isFinite(candidate))
|
|
216006
|
+
return candidate;
|
|
216007
|
+
if (typeof candidate === "string") {
|
|
216008
|
+
const parsed2 = Number(candidate);
|
|
216009
|
+
if (Number.isFinite(parsed2))
|
|
216010
|
+
return parsed2;
|
|
216011
|
+
}
|
|
216012
|
+
}
|
|
216013
|
+
return null;
|
|
216014
|
+
}
|
|
216015
|
+
function mapHorusecSeverity(raw) {
|
|
216016
|
+
const value = raw.toUpperCase();
|
|
216017
|
+
if (value.includes("CRITICAL"))
|
|
216018
|
+
return "CRITICAL";
|
|
216019
|
+
if (value.includes("HIGH"))
|
|
216020
|
+
return "HIGH";
|
|
216021
|
+
if (value.includes("MEDIUM"))
|
|
216022
|
+
return "MEDIUM";
|
|
216023
|
+
return "LOW";
|
|
216024
|
+
}
|
|
216025
|
+
function deriveCategory(ruleId, securityTool, details) {
|
|
216026
|
+
const haystack = `${ruleId} ${securityTool} ${details}`.toLowerCase();
|
|
216027
|
+
if (haystack.includes("secret") || haystack.includes("leak"))
|
|
216028
|
+
return "secret-exposure";
|
|
216029
|
+
if (haystack.includes("inject") || haystack.includes("sql"))
|
|
216030
|
+
return "injection";
|
|
216031
|
+
if (haystack.includes("xss") || haystack.includes("cross-site"))
|
|
216032
|
+
return "xss";
|
|
216033
|
+
if (haystack.includes("crypto") || haystack.includes("hash") || haystack.includes("cipher"))
|
|
216034
|
+
return "weak-cryptography";
|
|
216035
|
+
if (haystack.includes("auth") || haystack.includes("token") || haystack.includes("session"))
|
|
216036
|
+
return "authentication";
|
|
216037
|
+
if (haystack.includes("misconfig") || haystack.includes("config"))
|
|
216038
|
+
return "misconfiguration";
|
|
216039
|
+
if (haystack.includes("cve") || haystack.includes("dependency") || haystack.includes("trivy"))
|
|
216040
|
+
return "supply-chain-security";
|
|
216041
|
+
return "code-security";
|
|
216042
|
+
}
|
|
216043
|
+
|
|
215636
216044
|
// ../core/dist/scanner-registry.js
|
|
215637
216045
|
var ScannerRegistry = class {
|
|
215638
216046
|
scanners = /* @__PURE__ */ new Map();
|
|
@@ -215761,10 +216169,10 @@ var ScannerRegistry = class {
|
|
|
215761
216169
|
},
|
|
215762
216170
|
checkAvailable: async () => {
|
|
215763
216171
|
try {
|
|
215764
|
-
const { execFile:
|
|
215765
|
-
const { promisify:
|
|
215766
|
-
const
|
|
215767
|
-
await
|
|
216172
|
+
const { execFile: execFile10 } = await import("child_process");
|
|
216173
|
+
const { promisify: promisify11 } = await import("util");
|
|
216174
|
+
const execFileAsync10 = promisify11(execFile10);
|
|
216175
|
+
await execFileAsync10("semgrep", ["--version"], { timeout: 5e3 });
|
|
215768
216176
|
return true;
|
|
215769
216177
|
} catch {
|
|
215770
216178
|
return false;
|
|
@@ -215842,10 +216250,10 @@ var ScannerRegistry = class {
|
|
|
215842
216250
|
},
|
|
215843
216251
|
checkAvailable: async () => {
|
|
215844
216252
|
try {
|
|
215845
|
-
const { execFile:
|
|
215846
|
-
const { promisify:
|
|
215847
|
-
const
|
|
215848
|
-
await
|
|
216253
|
+
const { execFile: execFile10 } = await import("child_process");
|
|
216254
|
+
const { promisify: promisify11 } = await import("util");
|
|
216255
|
+
const execFileAsync10 = promisify11(execFile10);
|
|
216256
|
+
await execFileAsync10("npm", ["--version"], { timeout: 5e3 });
|
|
215849
216257
|
return true;
|
|
215850
216258
|
} catch {
|
|
215851
216259
|
return false;
|
|
@@ -215884,10 +216292,10 @@ var ScannerRegistry = class {
|
|
|
215884
216292
|
},
|
|
215885
216293
|
checkAvailable: async () => {
|
|
215886
216294
|
try {
|
|
215887
|
-
const { execFile:
|
|
215888
|
-
const { promisify:
|
|
215889
|
-
const
|
|
215890
|
-
await
|
|
216295
|
+
const { execFile: execFile10 } = await import("child_process");
|
|
216296
|
+
const { promisify: promisify11 } = await import("util");
|
|
216297
|
+
const execFileAsync10 = promisify11(execFile10);
|
|
216298
|
+
await execFileAsync10("docker", ["--version"], { timeout: 5e3 });
|
|
215891
216299
|
return true;
|
|
215892
216300
|
} catch {
|
|
215893
216301
|
return false;
|
|
@@ -215926,10 +216334,10 @@ var ScannerRegistry = class {
|
|
|
215926
216334
|
},
|
|
215927
216335
|
checkAvailable: async () => {
|
|
215928
216336
|
try {
|
|
215929
|
-
const { execFile:
|
|
215930
|
-
const { promisify:
|
|
215931
|
-
const
|
|
215932
|
-
await
|
|
216337
|
+
const { execFile: execFile10 } = await import("child_process");
|
|
216338
|
+
const { promisify: promisify11 } = await import("util");
|
|
216339
|
+
const execFileAsync10 = promisify11(execFile10);
|
|
216340
|
+
await execFileAsync10("bearer", ["--version"], { timeout: 5e3 });
|
|
215933
216341
|
return true;
|
|
215934
216342
|
} catch {
|
|
215935
216343
|
return false;
|
|
@@ -215959,6 +216367,90 @@ var ScannerRegistry = class {
|
|
|
215959
216367
|
};
|
|
215960
216368
|
}
|
|
215961
216369
|
});
|
|
216370
|
+
this.register({
|
|
216371
|
+
name: "trivy",
|
|
216372
|
+
version: "1.0.0",
|
|
216373
|
+
enabled: true,
|
|
216374
|
+
run: async (_filePaths, projectRoot, config) => {
|
|
216375
|
+
return await runTrivy(projectRoot, config);
|
|
216376
|
+
},
|
|
216377
|
+
checkAvailable: async () => {
|
|
216378
|
+
try {
|
|
216379
|
+
const { execFile: execFile10 } = await import("child_process");
|
|
216380
|
+
const { promisify: promisify11 } = await import("util");
|
|
216381
|
+
const execFileAsync10 = promisify11(execFile10);
|
|
216382
|
+
await execFileAsync10("trivy", ["--version"], { timeout: 5e3 });
|
|
216383
|
+
return true;
|
|
216384
|
+
} catch {
|
|
216385
|
+
return false;
|
|
216386
|
+
}
|
|
216387
|
+
},
|
|
216388
|
+
normalize: (finding, config) => {
|
|
216389
|
+
return {
|
|
216390
|
+
id: finding.id,
|
|
216391
|
+
severity: finding.severity,
|
|
216392
|
+
type: finding.type,
|
|
216393
|
+
category: finding.category,
|
|
216394
|
+
message: finding.message,
|
|
216395
|
+
file: finding.file,
|
|
216396
|
+
line: finding.line,
|
|
216397
|
+
column: finding.column,
|
|
216398
|
+
code: finding.code,
|
|
216399
|
+
aiScore: config.threshold,
|
|
216400
|
+
explainedScore: {
|
|
216401
|
+
score: config.threshold,
|
|
216402
|
+
band: "LOW",
|
|
216403
|
+
signalsTriggered: 0,
|
|
216404
|
+
variance: 0,
|
|
216405
|
+
topSignals: []
|
|
216406
|
+
},
|
|
216407
|
+
source: "trivy",
|
|
216408
|
+
ruleId: finding.ruleId
|
|
216409
|
+
};
|
|
216410
|
+
}
|
|
216411
|
+
});
|
|
216412
|
+
this.register({
|
|
216413
|
+
name: "horusec",
|
|
216414
|
+
version: "1.0.0",
|
|
216415
|
+
enabled: true,
|
|
216416
|
+
run: async (_filePaths, projectRoot, config) => {
|
|
216417
|
+
return await runHorusec(projectRoot, config);
|
|
216418
|
+
},
|
|
216419
|
+
checkAvailable: async () => {
|
|
216420
|
+
try {
|
|
216421
|
+
const { execFile: execFile10 } = await import("child_process");
|
|
216422
|
+
const { promisify: promisify11 } = await import("util");
|
|
216423
|
+
const execFileAsync10 = promisify11(execFile10);
|
|
216424
|
+
await execFileAsync10("horusec", ["version"], { timeout: 5e3 });
|
|
216425
|
+
return true;
|
|
216426
|
+
} catch {
|
|
216427
|
+
return false;
|
|
216428
|
+
}
|
|
216429
|
+
},
|
|
216430
|
+
normalize: (finding, config) => {
|
|
216431
|
+
return {
|
|
216432
|
+
id: finding.id,
|
|
216433
|
+
severity: finding.severity,
|
|
216434
|
+
type: finding.type,
|
|
216435
|
+
category: finding.category,
|
|
216436
|
+
message: finding.message,
|
|
216437
|
+
file: finding.file,
|
|
216438
|
+
line: finding.line,
|
|
216439
|
+
column: finding.column,
|
|
216440
|
+
code: finding.code,
|
|
216441
|
+
aiScore: config.threshold,
|
|
216442
|
+
explainedScore: {
|
|
216443
|
+
score: config.threshold,
|
|
216444
|
+
band: "LOW",
|
|
216445
|
+
signalsTriggered: 0,
|
|
216446
|
+
variance: 0,
|
|
216447
|
+
topSignals: []
|
|
216448
|
+
},
|
|
216449
|
+
source: "horusec",
|
|
216450
|
+
ruleId: finding.ruleId
|
|
216451
|
+
};
|
|
216452
|
+
}
|
|
216453
|
+
});
|
|
215962
216454
|
}
|
|
215963
216455
|
};
|
|
215964
216456
|
var scannerRegistry = new ScannerRegistry();
|
|
@@ -215992,7 +216484,7 @@ async function scanFiles(filePaths, configInput = {}, hooks = {}) {
|
|
|
215992
216484
|
findings: 0,
|
|
215993
216485
|
detail: "parse + score + local checks"
|
|
215994
216486
|
});
|
|
215995
|
-
const fileStat = await (0,
|
|
216487
|
+
const fileStat = await (0, import_promises4.stat)(filePath).catch(() => null);
|
|
215996
216488
|
if (!fileStat) {
|
|
215997
216489
|
processedFiles += 1;
|
|
215998
216490
|
hooks.onFileProgress?.({
|
|
@@ -216207,6 +216699,24 @@ function formatTerminalReport(report, options = {}) {
|
|
|
216207
216699
|
["medium", String(summary.security.findings.MEDIUM)],
|
|
216208
216700
|
["low", String(summary.security.findings.LOW)]
|
|
216209
216701
|
]));
|
|
216702
|
+
if (summary.security.sourceBreakdown) {
|
|
216703
|
+
const local = summary.security.sourceBreakdown.local;
|
|
216704
|
+
const external = summary.security.sourceBreakdown.external;
|
|
216705
|
+
lines.push("");
|
|
216706
|
+
lines.push(` ${c.bold}Finding Sources${c.reset}`);
|
|
216707
|
+
lines.push(metricLine([
|
|
216708
|
+
["local pass", String(local.total)],
|
|
216709
|
+
["external pass", String(external.total)]
|
|
216710
|
+
]));
|
|
216711
|
+
const localSources = formatSourceCounts(local.bySource);
|
|
216712
|
+
if (localSources) {
|
|
216713
|
+
lines.push(` ${c.dim}local sources${c.reset} ${localSources}`);
|
|
216714
|
+
}
|
|
216715
|
+
const externalSources = formatSourceCounts(external.bySource);
|
|
216716
|
+
if (externalSources) {
|
|
216717
|
+
lines.push(` ${c.dim}external sources${c.reset} ${externalSources}`);
|
|
216718
|
+
}
|
|
216719
|
+
}
|
|
216210
216720
|
lines.push("");
|
|
216211
216721
|
}
|
|
216212
216722
|
lines.push(` ${c.bold}Severity${c.reset}`);
|
|
@@ -216230,8 +216740,9 @@ function formatTerminalReport(report, options = {}) {
|
|
|
216230
216740
|
const shownFindings = findings.slice(0, maxFindings);
|
|
216231
216741
|
for (const finding of shownFindings) {
|
|
216232
216742
|
const sevColor = severityColor[finding.severity];
|
|
216743
|
+
const findingPass = classifyFindingPass2(finding.source);
|
|
216233
216744
|
lines.push(` ${sevColor}\u25CF ${finding.severity}${c.reset} ${c.bold}${finding.type}${c.reset} ${c.dim}${finding.id}${c.reset}`);
|
|
216234
|
-
lines.push(` ${c.orange}${finding.file}:${finding.line}${c.reset} ${c.dim}source=${finding.source}${c.reset} ${c.dim}ai=${finding.aiScore}${c.reset}`);
|
|
216745
|
+
lines.push(` ${c.orange}${finding.file}:${finding.line}${c.reset} ${c.dim}pass=${findingPass}${c.reset} ${c.dim}source=${finding.source}${c.reset} ${c.dim}ai=${finding.aiScore}${c.reset}`);
|
|
216235
216746
|
lines.push(` ${c.dim}${finding.message}${c.reset}`);
|
|
216236
216747
|
const snippet = formatCodeSnippet(finding.code, codePreviewLines);
|
|
216237
216748
|
if (snippet.length > 0) {
|
|
@@ -216279,9 +216790,18 @@ function formatSigned(value) {
|
|
|
216279
216790
|
return `+${value}`;
|
|
216280
216791
|
return String(value);
|
|
216281
216792
|
}
|
|
216793
|
+
function classifyFindingPass2(source) {
|
|
216794
|
+
if (source === "secret-detector" || source === "hallucination-detector" || source === "security-analyzer") {
|
|
216795
|
+
return "local";
|
|
216796
|
+
}
|
|
216797
|
+
return "external";
|
|
216798
|
+
}
|
|
216799
|
+
function formatSourceCounts(bySource) {
|
|
216800
|
+
return Object.entries(bySource).sort((a, b) => b[1] - a[1]).map(([source, count]) => `${source}:${count}`).join(" ");
|
|
216801
|
+
}
|
|
216282
216802
|
|
|
216283
216803
|
// src/commands/check.ts
|
|
216284
|
-
var
|
|
216804
|
+
var import_node_path12 = require("path");
|
|
216285
216805
|
|
|
216286
216806
|
// src/utils/console-buffer.ts
|
|
216287
216807
|
async function withBufferedAthenaCoreConsole(task) {
|
|
@@ -216324,11 +216844,11 @@ function normalizeCoreMessage(text) {
|
|
|
216324
216844
|
}
|
|
216325
216845
|
|
|
216326
216846
|
// src/utils/delta.ts
|
|
216327
|
-
var
|
|
216328
|
-
var
|
|
216329
|
-
var
|
|
216330
|
-
var ATHENA_DIR = (0,
|
|
216331
|
-
var SNAPSHOT_PATH = (0,
|
|
216847
|
+
var import_promises5 = require("fs/promises");
|
|
216848
|
+
var import_node_os2 = require("os");
|
|
216849
|
+
var import_node_path8 = require("path");
|
|
216850
|
+
var ATHENA_DIR = (0, import_node_path8.join)((0, import_node_os2.homedir)(), ".athena");
|
|
216851
|
+
var SNAPSHOT_PATH = (0, import_node_path8.join)(ATHENA_DIR, "scan-snapshots.json");
|
|
216332
216852
|
var severityWeights = {
|
|
216333
216853
|
CRITICAL: 8,
|
|
216334
216854
|
HIGH: 5,
|
|
@@ -216447,25 +216967,25 @@ function topFolderDeltas(current, previous) {
|
|
|
216447
216967
|
}
|
|
216448
216968
|
async function readSnapshots() {
|
|
216449
216969
|
try {
|
|
216450
|
-
return JSON.parse(await (0,
|
|
216970
|
+
return JSON.parse(await (0, import_promises5.readFile)(SNAPSHOT_PATH, "utf8"));
|
|
216451
216971
|
} catch {
|
|
216452
216972
|
return {};
|
|
216453
216973
|
}
|
|
216454
216974
|
}
|
|
216455
216975
|
async function writeSnapshots(snapshots) {
|
|
216456
|
-
await (0,
|
|
216457
|
-
await (0,
|
|
216976
|
+
await (0, import_promises5.mkdir)(ATHENA_DIR, { recursive: true });
|
|
216977
|
+
await (0, import_promises5.writeFile)(SNAPSHOT_PATH, `${JSON.stringify(snapshots, null, 2)}
|
|
216458
216978
|
`, "utf8");
|
|
216459
216979
|
}
|
|
216460
216980
|
function folderForPath(filePath, projectRoot) {
|
|
216461
|
-
const path = ((0,
|
|
216462
|
-
const folder = (0,
|
|
216981
|
+
const path = ((0, import_node_path8.isAbsolute)(filePath) ? (0, import_node_path8.relative)(projectRoot, filePath) : filePath).split("\\").join("/");
|
|
216982
|
+
const folder = (0, import_node_path8.dirname)(path).split("\\").join("/");
|
|
216463
216983
|
return folder === "." ? "<root>" : folder.split("/")[0] ?? "<root>";
|
|
216464
216984
|
}
|
|
216465
216985
|
|
|
216466
216986
|
// src/utils/file-filter.ts
|
|
216467
|
-
var
|
|
216468
|
-
var
|
|
216987
|
+
var import_promises6 = require("fs/promises");
|
|
216988
|
+
var import_node_path9 = require("path");
|
|
216469
216989
|
var supported = /* @__PURE__ */ new Set([".js", ".jsx", ".ts", ".tsx"]);
|
|
216470
216990
|
var ignoredDirs = /* @__PURE__ */ new Set([
|
|
216471
216991
|
"node_modules",
|
|
@@ -216492,7 +217012,7 @@ function isSourceFile(filePath) {
|
|
|
216492
217012
|
}
|
|
216493
217013
|
function isExcludedPath(filePath, root, excludes = []) {
|
|
216494
217014
|
if (excludes.length === 0) return false;
|
|
216495
|
-
const normalizedRelativePath = (0,
|
|
217015
|
+
const normalizedRelativePath = (0, import_node_path9.relative)(root, filePath).split("\\").join("/");
|
|
216496
217016
|
const relativeSegments = normalizedRelativePath.split("/").filter(Boolean);
|
|
216497
217017
|
return excludes.some((pattern) => {
|
|
216498
217018
|
const normalizedPattern = pattern.replace(/^\.\//, "").replace(/\\/g, "/").replace(/^\/+/, "").replace(/\/+$/, "");
|
|
@@ -216505,20 +217025,20 @@ function isExcludedPath(filePath, root, excludes = []) {
|
|
|
216505
217025
|
});
|
|
216506
217026
|
}
|
|
216507
217027
|
async function findSourceFiles(root, excludes = []) {
|
|
216508
|
-
const rootStat = await (0,
|
|
217028
|
+
const rootStat = await (0, import_promises6.stat)(root).catch(() => null);
|
|
216509
217029
|
if (!rootStat) return [];
|
|
216510
217030
|
if (rootStat.isFile()) return isSourceFile(root) && !isExcludedPath(root, root, excludes) ? [root] : [];
|
|
216511
217031
|
const output = [];
|
|
216512
|
-
await
|
|
217032
|
+
await walk2(root, root, output, excludes);
|
|
216513
217033
|
return output;
|
|
216514
217034
|
}
|
|
216515
|
-
async function
|
|
216516
|
-
const entries = await (0,
|
|
217035
|
+
async function walk2(dir, root, output, excludes) {
|
|
217036
|
+
const entries = await (0, import_promises6.readdir)(dir, { withFileTypes: true }).catch(() => []);
|
|
216517
217037
|
for (const entry of entries) {
|
|
216518
|
-
const fullPath = (0,
|
|
217038
|
+
const fullPath = (0, import_node_path9.join)(dir, entry.name);
|
|
216519
217039
|
if (entry.isDirectory()) {
|
|
216520
217040
|
if (!ignoredDirs.has(entry.name) && !isExcludedPath(fullPath, root, excludes)) {
|
|
216521
|
-
await
|
|
217041
|
+
await walk2(fullPath, root, output, excludes);
|
|
216522
217042
|
}
|
|
216523
217043
|
continue;
|
|
216524
217044
|
}
|
|
@@ -216529,16 +217049,16 @@ async function walk(dir, root, output, excludes) {
|
|
|
216529
217049
|
}
|
|
216530
217050
|
|
|
216531
217051
|
// src/utils/git.ts
|
|
216532
|
-
var
|
|
216533
|
-
var
|
|
216534
|
-
var
|
|
217052
|
+
var import_node_child_process8 = require("child_process");
|
|
217053
|
+
var import_node_util8 = require("util");
|
|
217054
|
+
var execFileAsync8 = (0, import_node_util8.promisify)(import_node_child_process8.execFile);
|
|
216535
217055
|
function logGitWarning(context, error) {
|
|
216536
217056
|
const message = error instanceof Error ? error.message : String(error);
|
|
216537
217057
|
console.warn(`[athena-cli] ${context}: ${message}`);
|
|
216538
217058
|
}
|
|
216539
217059
|
async function getGitRoot() {
|
|
216540
217060
|
try {
|
|
216541
|
-
const { stdout } = await
|
|
217061
|
+
const { stdout } = await execFileAsync8("git", ["rev-parse", "--show-toplevel"]);
|
|
216542
217062
|
return stdout.trim();
|
|
216543
217063
|
} catch (error) {
|
|
216544
217064
|
logGitWarning("Unable to resolve git root", error);
|
|
@@ -216547,7 +217067,7 @@ async function getGitRoot() {
|
|
|
216547
217067
|
}
|
|
216548
217068
|
async function getGitHooksDir() {
|
|
216549
217069
|
try {
|
|
216550
|
-
const { stdout } = await
|
|
217070
|
+
const { stdout } = await execFileAsync8("git", ["rev-parse", "--git-path", "hooks"]);
|
|
216551
217071
|
return stdout.trim();
|
|
216552
217072
|
} catch (error) {
|
|
216553
217073
|
logGitWarning("Unable to resolve git hooks directory", error);
|
|
@@ -216556,7 +217076,7 @@ async function getGitHooksDir() {
|
|
|
216556
217076
|
}
|
|
216557
217077
|
async function getStagedFiles() {
|
|
216558
217078
|
try {
|
|
216559
|
-
const { stdout } = await
|
|
217079
|
+
const { stdout } = await execFileAsync8("git", ["diff", "--cached", "--name-only", "--diff-filter=ACM"]);
|
|
216560
217080
|
return stdout.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
216561
217081
|
} catch (error) {
|
|
216562
217082
|
logGitWarning("Unable to read staged files", error);
|
|
@@ -216565,11 +217085,11 @@ async function getStagedFiles() {
|
|
|
216565
217085
|
}
|
|
216566
217086
|
|
|
216567
217087
|
// src/utils/history.ts
|
|
216568
|
-
var
|
|
216569
|
-
var
|
|
216570
|
-
var
|
|
216571
|
-
var ATHENA_DIR2 = (0,
|
|
216572
|
-
var HISTORY_PATH = (0,
|
|
217088
|
+
var import_promises7 = require("fs/promises");
|
|
217089
|
+
var import_node_os3 = require("os");
|
|
217090
|
+
var import_node_path10 = require("path");
|
|
217091
|
+
var ATHENA_DIR2 = (0, import_node_path10.join)((0, import_node_os3.homedir)(), ".athena");
|
|
217092
|
+
var HISTORY_PATH = (0, import_node_path10.join)(ATHENA_DIR2, "scan-history.jsonl");
|
|
216573
217093
|
var MAX_HISTORY_LINES = 300;
|
|
216574
217094
|
function logHistoryWarning(context, error) {
|
|
216575
217095
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -216577,17 +217097,17 @@ function logHistoryWarning(context, error) {
|
|
|
216577
217097
|
}
|
|
216578
217098
|
async function appendScanHistory(entry) {
|
|
216579
217099
|
try {
|
|
216580
|
-
await (0,
|
|
217100
|
+
await (0, import_promises7.mkdir)(ATHENA_DIR2, { recursive: true });
|
|
216581
217101
|
let lines = [];
|
|
216582
217102
|
try {
|
|
216583
|
-
const existing = await (0,
|
|
217103
|
+
const existing = await (0, import_promises7.readFile)(HISTORY_PATH, "utf8");
|
|
216584
217104
|
lines = existing.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
216585
217105
|
} catch (error) {
|
|
216586
217106
|
logHistoryWarning("History file not readable, starting new history", error);
|
|
216587
217107
|
}
|
|
216588
217108
|
lines.push(JSON.stringify(entry));
|
|
216589
217109
|
const trimmed = lines.slice(-MAX_HISTORY_LINES);
|
|
216590
|
-
await (0,
|
|
217110
|
+
await (0, import_promises7.writeFile)(HISTORY_PATH, `${trimmed.join("\n")}
|
|
216591
217111
|
`, "utf8");
|
|
216592
217112
|
} catch (error) {
|
|
216593
217113
|
logHistoryWarning("Failed to persist scan history", error);
|
|
@@ -216595,7 +217115,7 @@ async function appendScanHistory(entry) {
|
|
|
216595
217115
|
}
|
|
216596
217116
|
async function getRecentScanHistory(limit = 3) {
|
|
216597
217117
|
try {
|
|
216598
|
-
const content = await (0,
|
|
217118
|
+
const content = await (0, import_promises7.readFile)(HISTORY_PATH, "utf8");
|
|
216599
217119
|
const lines = content.split("\n").map((line) => line.trim()).filter(Boolean).slice(-Math.max(1, limit));
|
|
216600
217120
|
return lines.map((line) => {
|
|
216601
217121
|
try {
|
|
@@ -216628,7 +217148,7 @@ function formatRecentHistory(entries) {
|
|
|
216628
217148
|
}
|
|
216629
217149
|
|
|
216630
217150
|
// src/utils/scan-progress.ts
|
|
216631
|
-
var
|
|
217151
|
+
var import_node_path11 = require("path");
|
|
216632
217152
|
|
|
216633
217153
|
// src/utils/colors.ts
|
|
216634
217154
|
var c2 = {
|
|
@@ -216722,7 +217242,7 @@ function createScanProgressRenderer(enabled) {
|
|
|
216722
217242
|
onProgress: (event) => {
|
|
216723
217243
|
total = event.total;
|
|
216724
217244
|
currentPhase = formatPhase(event);
|
|
216725
|
-
currentFile = event.filePath ? (0,
|
|
217245
|
+
currentFile = event.filePath ? (0, import_node_path11.basename)(event.filePath) : "";
|
|
216726
217246
|
maybePrintMilestone(event);
|
|
216727
217247
|
if (event.status === "scanned" || event.status === "skipped" || event.status === "missing") {
|
|
216728
217248
|
processed = event.index;
|
|
@@ -216733,7 +217253,7 @@ function createScanProgressRenderer(enabled) {
|
|
|
216733
217253
|
},
|
|
216734
217254
|
onStage: (event) => {
|
|
216735
217255
|
currentPhase = formatPhase(event);
|
|
216736
|
-
currentFile = event.filePath ? (0,
|
|
217256
|
+
currentFile = event.filePath ? (0, import_node_path11.basename)(event.filePath) : "";
|
|
216737
217257
|
maybePrintMilestone(event);
|
|
216738
217258
|
if (event.phase === "external-scanners") {
|
|
216739
217259
|
total = Math.max(total, event.total);
|
|
@@ -216773,8 +217293,8 @@ function formatPhase(event) {
|
|
|
216773
217293
|
}
|
|
216774
217294
|
function formatMilestone(event) {
|
|
216775
217295
|
if (event.phase === "prepare") return "step 1/6 discover files";
|
|
216776
|
-
if (event.phase === "security-analysis") return `step 2/6 analyze ${(0,
|
|
216777
|
-
if (event.phase === "files" && event.status === "scanning") return `step 3/6 parse ${(0,
|
|
217296
|
+
if (event.phase === "security-analysis") return `step 2/6 analyze ${(0, import_node_path11.basename)(event.filePath)}`;
|
|
217297
|
+
if (event.phase === "files" && event.status === "scanning") return `step 3/6 parse ${(0, import_node_path11.basename)(event.filePath)}`;
|
|
216778
217298
|
if (event.phase === "files" && event.status === "scanned" && event.index === event.total) return "step 4/6 local file pass complete";
|
|
216779
217299
|
if (event.phase === "external-scanners") return `step 5/6 ${event.detail ?? "run external scanners"}`;
|
|
216780
217300
|
if (event.phase === "report") return "step 6/6 build report";
|
|
@@ -216836,8 +217356,10 @@ async function checkCommand(files, options) {
|
|
|
216836
217356
|
config.nodejsscan = { ...config.nodejsscan, enabled: options.nodejsscan !== false };
|
|
216837
217357
|
config.bearer = { ...config.bearer, enabled: options.bearer !== false };
|
|
216838
217358
|
config.semgrep.enabled = options.semgrep !== false;
|
|
217359
|
+
config.trivy = { ...config.trivy, enabled: options.trivy !== false };
|
|
217360
|
+
config.horusec = { ...config.horusec, enabled: options.horusec !== false };
|
|
216839
217361
|
const selected = files.length > 0 ? files : await getStagedFiles();
|
|
216840
|
-
const sourceFiles = selected.filter(isSourceFile).map((file) => (0,
|
|
217362
|
+
const sourceFiles = selected.filter(isSourceFile).map((file) => (0, import_node_path12.resolve)(process.cwd(), file)).filter((file) => !isExcludedPath(file, process.cwd(), config.exclude));
|
|
216841
217363
|
if (!options.quietHeader) {
|
|
216842
217364
|
if (process.stdout.isTTY) {
|
|
216843
217365
|
clearScreen();
|
|
@@ -216885,19 +217407,203 @@ function parseMaxFindings(raw) {
|
|
|
216885
217407
|
}
|
|
216886
217408
|
|
|
216887
217409
|
// src/commands/doctor.ts
|
|
216888
|
-
var
|
|
216889
|
-
var
|
|
216890
|
-
|
|
216891
|
-
|
|
217410
|
+
var import_node_child_process10 = require("child_process");
|
|
217411
|
+
var import_node_util10 = require("util");
|
|
217412
|
+
|
|
217413
|
+
// src/commands/setup.ts
|
|
217414
|
+
var import_node_child_process9 = require("child_process");
|
|
217415
|
+
var import_node_util9 = require("util");
|
|
217416
|
+
var execAsync = (0, import_node_util9.promisify)(import_node_child_process9.exec);
|
|
217417
|
+
function getSemgrepInstallCommand(platform) {
|
|
217418
|
+
if (platform === "darwin") return "brew install semgrep";
|
|
217419
|
+
if (platform === "win32") return "choco install semgrep -y";
|
|
217420
|
+
return "python3 -m pip install --user semgrep";
|
|
217421
|
+
}
|
|
217422
|
+
function getTrivyInstallCommand(platform) {
|
|
217423
|
+
if (platform === "darwin") return "brew install trivy";
|
|
217424
|
+
if (platform === "win32") return "choco install trivy -y";
|
|
217425
|
+
return void 0;
|
|
217426
|
+
}
|
|
217427
|
+
function getTrivyManualInstallCommand(platform) {
|
|
217428
|
+
return getTrivyInstallCommand(platform) ?? "https://trivy.dev/latest/getting-started/installation/";
|
|
217429
|
+
}
|
|
217430
|
+
function getHorusecInstallCommand(platform) {
|
|
217431
|
+
if (platform === "win32") {
|
|
217432
|
+
return 'curl -k "https://github.com/ZupIT/horusec/releases/latest/download/horusec_win_amd64.exe" -o "./horusec.exe" -L';
|
|
217433
|
+
}
|
|
217434
|
+
return "curl -fsSL https://raw.githubusercontent.com/ZupIT/horusec/master/deployments/scripts/install.sh | bash -s latest";
|
|
217435
|
+
}
|
|
217436
|
+
async function setupSemgrepCommand(options = {}) {
|
|
217437
|
+
const installCommand = getSemgrepInstallCommand(process.platform);
|
|
217438
|
+
console.log("Semgrep setup");
|
|
217439
|
+
console.log(`Install command for this system:
|
|
217440
|
+
${installCommand}`);
|
|
217441
|
+
if (!options.auto) {
|
|
217442
|
+
console.log("Run command above, then verify with: semgrep --version");
|
|
217443
|
+
return;
|
|
217444
|
+
}
|
|
217445
|
+
try {
|
|
217446
|
+
console.log("Running installer...");
|
|
217447
|
+
const { stdout, stderr } = await execAsync(installCommand, { timeout: 12e4, maxBuffer: 1024 * 1024 });
|
|
217448
|
+
if (stdout.trim()) console.log(stdout.trim());
|
|
217449
|
+
if (stderr.trim()) console.log(stderr.trim());
|
|
217450
|
+
console.log("Semgrep install command completed. Verify with: semgrep --version");
|
|
217451
|
+
} catch (error) {
|
|
217452
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
217453
|
+
console.error(`Semgrep install failed: ${message}`);
|
|
217454
|
+
process.exitCode = 1;
|
|
217455
|
+
}
|
|
217456
|
+
}
|
|
217457
|
+
function getSetupAllPlan(platform) {
|
|
217458
|
+
return [
|
|
217459
|
+
{
|
|
217460
|
+
id: "eslint",
|
|
217461
|
+
name: "ESLint + eslint-plugin-security",
|
|
217462
|
+
includedWithAthena: true,
|
|
217463
|
+
note: "Bundled as Athena optional dependencies and used by the ESLint scanner when present."
|
|
217464
|
+
},
|
|
217465
|
+
{
|
|
217466
|
+
id: "npm-audit",
|
|
217467
|
+
name: "npm audit",
|
|
217468
|
+
includedWithAthena: true,
|
|
217469
|
+
note: "Uses npm CLI that ships with Node.js. No separate scanner package install required."
|
|
217470
|
+
},
|
|
217471
|
+
{
|
|
217472
|
+
id: "semgrep",
|
|
217473
|
+
name: "Semgrep",
|
|
217474
|
+
includedWithAthena: false,
|
|
217475
|
+
autoInstallCommand: getSemgrepInstallCommand(platform),
|
|
217476
|
+
manualInstallCommand: getSemgrepInstallCommand(platform),
|
|
217477
|
+
note: "External binary scanner. Optional, but improves SAST coverage."
|
|
217478
|
+
},
|
|
217479
|
+
{
|
|
217480
|
+
id: "docker",
|
|
217481
|
+
name: "Docker (for nodejsscan)",
|
|
217482
|
+
includedWithAthena: false,
|
|
217483
|
+
note: "Required runtime for nodejsscan container execution; install from Docker Desktop/package manager."
|
|
217484
|
+
},
|
|
217485
|
+
{
|
|
217486
|
+
id: "bearer",
|
|
217487
|
+
name: "Bearer CLI",
|
|
217488
|
+
includedWithAthena: false,
|
|
217489
|
+
autoInstallCommand: "npm install -g @bearer/cli",
|
|
217490
|
+
manualInstallCommand: "npm install -g @bearer/cli",
|
|
217491
|
+
note: "External CLI scanner for privacy and data-flow analysis."
|
|
217492
|
+
},
|
|
217493
|
+
{
|
|
217494
|
+
id: "trivy",
|
|
217495
|
+
name: "Trivy",
|
|
217496
|
+
includedWithAthena: false,
|
|
217497
|
+
autoInstallCommand: getTrivyInstallCommand(platform),
|
|
217498
|
+
manualInstallCommand: getTrivyManualInstallCommand(platform),
|
|
217499
|
+
note: "External unified scanner for dependency vulnerabilities, secrets, and misconfigurations."
|
|
217500
|
+
},
|
|
217501
|
+
{
|
|
217502
|
+
id: "horusec",
|
|
217503
|
+
name: "Horusec",
|
|
217504
|
+
includedWithAthena: false,
|
|
217505
|
+
autoInstallCommand: getHorusecInstallCommand(platform),
|
|
217506
|
+
manualInstallCommand: getHorusecInstallCommand(platform),
|
|
217507
|
+
note: "External multi-language SAST orchestrator. Docker recommended for full analysis coverage."
|
|
217508
|
+
}
|
|
217509
|
+
];
|
|
217510
|
+
}
|
|
217511
|
+
function getAutoInstallPlans(plan, missingToolIds) {
|
|
217512
|
+
const missing = new Set(missingToolIds);
|
|
217513
|
+
return plan.filter((tool) => missing.has(tool.id) && Boolean(tool.autoInstallCommand));
|
|
217514
|
+
}
|
|
217515
|
+
async function installSetupPlans(plan) {
|
|
217516
|
+
let failed = false;
|
|
217517
|
+
for (const tool of plan) {
|
|
217518
|
+
if (!tool.autoInstallCommand) continue;
|
|
217519
|
+
try {
|
|
217520
|
+
console.log(`
|
|
217521
|
+
Installing ${tool.name}...`);
|
|
217522
|
+
const { stdout, stderr } = await execAsync(tool.autoInstallCommand, { timeout: 18e4, maxBuffer: 1024 * 1024 });
|
|
217523
|
+
if (stdout.trim()) console.log(stdout.trim());
|
|
217524
|
+
if (stderr.trim()) console.log(stderr.trim());
|
|
217525
|
+
console.log(`Completed: ${tool.name}`);
|
|
217526
|
+
} catch (error) {
|
|
217527
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
217528
|
+
console.error(`Failed: ${tool.name} (${message})`);
|
|
217529
|
+
failed = true;
|
|
217530
|
+
}
|
|
217531
|
+
}
|
|
217532
|
+
return !failed;
|
|
217533
|
+
}
|
|
217534
|
+
async function setupAllCommand(options = {}) {
|
|
217535
|
+
const plan = getSetupAllPlan(process.platform);
|
|
217536
|
+
console.log("Athena scanner setup plan\n");
|
|
217537
|
+
for (const tool of plan) {
|
|
217538
|
+
const inclusion = tool.includedWithAthena ? "included" : "external";
|
|
217539
|
+
console.log(`- ${tool.name} (${inclusion})`);
|
|
217540
|
+
console.log(` ${tool.note}`);
|
|
217541
|
+
if (tool.manualInstallCommand && !tool.includedWithAthena) {
|
|
217542
|
+
console.log(` install: ${tool.manualInstallCommand}`);
|
|
217543
|
+
}
|
|
217544
|
+
}
|
|
217545
|
+
if (!options.auto) {
|
|
217546
|
+
console.log("\nUse --auto to run supported install commands automatically.");
|
|
217547
|
+
return;
|
|
217548
|
+
}
|
|
217549
|
+
const success = await installSetupPlans(plan);
|
|
217550
|
+
if (!success) {
|
|
217551
|
+
console.log("\nSome installs failed. You can run their manual commands from the setup plan above.");
|
|
217552
|
+
process.exitCode = 1;
|
|
217553
|
+
return;
|
|
217554
|
+
}
|
|
217555
|
+
console.log("\nSetup complete. Run `athena doctor` to verify tool availability.");
|
|
217556
|
+
}
|
|
217557
|
+
|
|
217558
|
+
// src/commands/doctor.ts
|
|
217559
|
+
var execFileAsync9 = (0, import_node_util10.promisify)(import_node_child_process10.execFile);
|
|
217560
|
+
async function doctorCommand(options = {}) {
|
|
217561
|
+
let statuses = await collectDoctorStatuses();
|
|
217562
|
+
printDoctorStatuses(statuses);
|
|
217563
|
+
if (options.fix) {
|
|
217564
|
+
const setupPlan = getSetupAllPlan(process.platform);
|
|
217565
|
+
const installable = getAutoInstallPlans(
|
|
217566
|
+
setupPlan,
|
|
217567
|
+
statuses.filter((status) => !status.ok).map((status) => status.id)
|
|
217568
|
+
);
|
|
217569
|
+
if (installable.length === 0) {
|
|
217570
|
+
console.log(`
|
|
217571
|
+
${c2.green}fix:${c2.reset} no auto-installable missing tools found`);
|
|
217572
|
+
printDoctorTips(statuses, true);
|
|
217573
|
+
return;
|
|
217574
|
+
}
|
|
217575
|
+
console.log(`
|
|
217576
|
+
${c2.yellow}fix:${c2.reset} attempting automatic install for missing tools...`);
|
|
217577
|
+
const success = await installSetupPlans(installable);
|
|
217578
|
+
statuses = await collectDoctorStatuses();
|
|
217579
|
+
console.log(`
|
|
217580
|
+
${c2.bold}Athena doctor (after fix)${c2.reset}
|
|
217581
|
+
`);
|
|
217582
|
+
printDoctorStatuses(statuses);
|
|
217583
|
+
if (!success) {
|
|
217584
|
+
console.log(`
|
|
217585
|
+
${c2.yellow}fix:${c2.reset} some installs failed`);
|
|
217586
|
+
process.exitCode = 1;
|
|
217587
|
+
}
|
|
217588
|
+
}
|
|
217589
|
+
printDoctorTips(statuses, Boolean(options.fix));
|
|
217590
|
+
}
|
|
217591
|
+
async function collectDoctorStatuses() {
|
|
217592
|
+
const plan = getSetupAllPlan(process.platform);
|
|
217593
|
+
const findPlan = (id) => plan.find((tool) => tool.id === id);
|
|
216892
217594
|
const statuses = await Promise.all([
|
|
216893
|
-
checkTool("node", ["--version"], "required runtime"),
|
|
216894
|
-
checkTool("npm", ["--version"], "required package manager"),
|
|
216895
|
-
checkTool("semgrep", ["--version"], "optional: deep SAST findings"),
|
|
216896
|
-
|
|
216897
|
-
checkTool("docker", ["--version"], "optional: required for nodejsscan"),
|
|
216898
|
-
checkTool("bearer", ["--version"], "optional: privacy & data flow analysis"),
|
|
216899
|
-
checkTool("trivy", ["--version"], "optional: IaC/container/dependency findings")
|
|
217595
|
+
checkTool("node", "node", ["--version"], "required runtime"),
|
|
217596
|
+
checkTool("npm", "npm", ["--version"], "required package manager"),
|
|
217597
|
+
checkTool("semgrep", "semgrep", ["--version"], "optional: deep SAST findings", findPlan("semgrep")),
|
|
217598
|
+
checkBundledEslint(findPlan("eslint")),
|
|
217599
|
+
checkTool("docker", "docker", ["--version"], "optional: required for nodejsscan", findPlan("docker")),
|
|
217600
|
+
checkTool("bearer", "bearer", ["--version"], "optional: privacy & data flow analysis", findPlan("bearer")),
|
|
217601
|
+
checkTool("trivy", "trivy", ["--version"], "optional: IaC/container/dependency/misconfig findings", findPlan("trivy")),
|
|
217602
|
+
checkTool("horusec", "horusec", ["version"], "optional: multi-tool SAST orchestrator", findPlan("horusec"))
|
|
216900
217603
|
]);
|
|
217604
|
+
return statuses;
|
|
217605
|
+
}
|
|
217606
|
+
function printDoctorStatuses(statuses) {
|
|
216901
217607
|
console.log("Athena doctor\n");
|
|
216902
217608
|
for (const status of statuses) {
|
|
216903
217609
|
const mark = status.ok ? `${c2.green}\u2713${c2.reset}` : `${c2.red}\u2717${c2.reset}`;
|
|
@@ -216905,49 +217611,82 @@ async function doctorCommand() {
|
|
|
216905
217611
|
console.log(` ${mark} ${status.name.padEnd(10)} ${version}`);
|
|
216906
217612
|
if (status.note) console.log(` ${c2.dim}${status.note}${c2.reset}`);
|
|
216907
217613
|
}
|
|
216908
|
-
|
|
216909
|
-
|
|
217614
|
+
}
|
|
217615
|
+
function printDoctorTips(statuses, fixed) {
|
|
217616
|
+
const autoFixableMissing = statuses.filter((status) => !status.ok && status.autoFixable);
|
|
217617
|
+
if (autoFixableMissing.length > 0 && !fixed) {
|
|
216910
217618
|
console.log(`
|
|
216911
|
-
${c2.yellow}tip:${c2.reset}
|
|
217619
|
+
${c2.yellow}tip:${c2.reset} run ${c2.bold}athena doctor --fix${c2.reset} to auto-install supported missing tools`);
|
|
216912
217620
|
}
|
|
216913
|
-
const eslint = statuses.find((item) => item.
|
|
217621
|
+
const eslint = statuses.find((item) => item.id === "eslint");
|
|
216914
217622
|
if (!eslint?.ok) {
|
|
216915
|
-
console.log(` ${c2.yellow}tip:${c2.reset}
|
|
217623
|
+
console.log(` ${c2.yellow}tip:${c2.reset} ESLint scanner is bundled with Athena optional deps; reinstall Athena or run ${c2.bold}npm install${c2.reset} in repo if missing`);
|
|
216916
217624
|
}
|
|
216917
|
-
const docker = statuses.find((item) => item.
|
|
217625
|
+
const docker = statuses.find((item) => item.id === "docker");
|
|
216918
217626
|
if (!docker?.ok) {
|
|
216919
217627
|
console.log(` ${c2.yellow}tip:${c2.reset} install Docker to enable nodejsscan scanner`);
|
|
216920
217628
|
}
|
|
216921
|
-
const
|
|
216922
|
-
|
|
216923
|
-
console.log(` ${c2.yellow}tip:${c2.reset} install Bearer with ${c2.bold}npm install -g @bearer/cli${c2.reset}`);
|
|
217629
|
+
for (const status of statuses.filter((item) => !item.ok && item.manualInstallCommand && !item.autoFixable)) {
|
|
217630
|
+
console.log(` ${c2.yellow}tip:${c2.reset} install ${status.name} with ${c2.bold}${status.manualInstallCommand}${c2.reset}`);
|
|
216924
217631
|
}
|
|
216925
217632
|
}
|
|
216926
|
-
async function checkTool(name, args, note) {
|
|
217633
|
+
async function checkTool(id, name, args, note, plan) {
|
|
216927
217634
|
try {
|
|
216928
|
-
const { stdout, stderr } = await
|
|
217635
|
+
const { stdout, stderr } = await execFileAsync9(name, args, { timeout: 15e3, maxBuffer: 1024 * 1024 });
|
|
216929
217636
|
const raw = `${stdout}
|
|
216930
217637
|
${stderr}`.trim();
|
|
216931
217638
|
const line = raw.split(/\r?\n/).find((value) => value.trim().length > 0) ?? "ok";
|
|
216932
217639
|
return {
|
|
217640
|
+
id,
|
|
216933
217641
|
name,
|
|
216934
217642
|
ok: true,
|
|
216935
217643
|
version: line.trim(),
|
|
216936
|
-
note
|
|
217644
|
+
note,
|
|
217645
|
+
manualInstallCommand: plan?.manualInstallCommand,
|
|
217646
|
+
autoFixable: Boolean(plan?.autoInstallCommand)
|
|
216937
217647
|
};
|
|
216938
217648
|
} catch {
|
|
216939
217649
|
return {
|
|
217650
|
+
id,
|
|
216940
217651
|
name,
|
|
216941
217652
|
ok: false,
|
|
216942
217653
|
version: "not found",
|
|
216943
|
-
note
|
|
217654
|
+
note,
|
|
217655
|
+
manualInstallCommand: plan?.manualInstallCommand,
|
|
217656
|
+
autoFixable: Boolean(plan?.autoInstallCommand)
|
|
217657
|
+
};
|
|
217658
|
+
}
|
|
217659
|
+
}
|
|
217660
|
+
async function checkBundledEslint(plan) {
|
|
217661
|
+
try {
|
|
217662
|
+
const eslintModule = await import("eslint");
|
|
217663
|
+
await import("eslint-plugin-security");
|
|
217664
|
+
const version = eslintModule.ESLint?.version;
|
|
217665
|
+
return {
|
|
217666
|
+
id: "eslint",
|
|
217667
|
+
name: "eslint",
|
|
217668
|
+
ok: true,
|
|
217669
|
+
version: version ? `v${version} (bundled)` : "bundled module available",
|
|
217670
|
+
note: "optional: JavaScript/TypeScript linting via Athena bundled deps",
|
|
217671
|
+
manualInstallCommand: plan?.manualInstallCommand,
|
|
217672
|
+
autoFixable: Boolean(plan?.autoInstallCommand)
|
|
217673
|
+
};
|
|
217674
|
+
} catch {
|
|
217675
|
+
return {
|
|
217676
|
+
id: "eslint",
|
|
217677
|
+
name: "eslint",
|
|
217678
|
+
ok: false,
|
|
217679
|
+
version: "not found",
|
|
217680
|
+
note: "optional: JavaScript/TypeScript linting via Athena bundled deps",
|
|
217681
|
+
manualInstallCommand: plan?.manualInstallCommand,
|
|
217682
|
+
autoFixable: Boolean(plan?.autoInstallCommand)
|
|
216944
217683
|
};
|
|
216945
217684
|
}
|
|
216946
217685
|
}
|
|
216947
217686
|
|
|
216948
217687
|
// src/commands/init.ts
|
|
216949
|
-
var
|
|
216950
|
-
var
|
|
217688
|
+
var import_promises8 = require("fs/promises");
|
|
217689
|
+
var import_node_path13 = require("path");
|
|
216951
217690
|
async function initCommand() {
|
|
216952
217691
|
const root = await getGitRoot();
|
|
216953
217692
|
const hooksDir = await getGitHooksDir();
|
|
@@ -216956,14 +217695,14 @@ async function initCommand() {
|
|
|
216956
217695
|
process.exitCode = 1;
|
|
216957
217696
|
return;
|
|
216958
217697
|
}
|
|
216959
|
-
const hookPath = (0,
|
|
217698
|
+
const hookPath = (0, import_node_path13.join)(hooksDir, "pre-commit");
|
|
216960
217699
|
const hook = [
|
|
216961
217700
|
"#!/bin/sh",
|
|
216962
217701
|
'echo "athena: checking staged JS/TS files"',
|
|
216963
217702
|
"npx athena check"
|
|
216964
217703
|
].join("\n");
|
|
216965
|
-
await (0,
|
|
216966
|
-
await (0,
|
|
217704
|
+
await (0, import_promises8.mkdir)((0, import_node_path13.dirname)(hookPath), { recursive: true });
|
|
217705
|
+
await (0, import_promises8.writeFile)(hookPath, `${hook}
|
|
216967
217706
|
`, { mode: 493 });
|
|
216968
217707
|
console.log(`Athena pre-commit hook installed at ${hookPath}`);
|
|
216969
217708
|
}
|
|
@@ -216972,9 +217711,9 @@ async function initCommand() {
|
|
|
216972
217711
|
var import_node_readline = require("readline");
|
|
216973
217712
|
|
|
216974
217713
|
// src/commands/scan.ts
|
|
216975
|
-
var
|
|
217714
|
+
var import_node_path14 = require("path");
|
|
216976
217715
|
async function scanCommand(dir, options) {
|
|
216977
|
-
const root = (0,
|
|
217716
|
+
const root = (0, import_node_path14.resolve)(process.cwd(), dir);
|
|
216978
217717
|
const config = mergeConfig({
|
|
216979
217718
|
threshold: Number(options.threshold)
|
|
216980
217719
|
});
|
|
@@ -216983,6 +217722,8 @@ async function scanCommand(dir, options) {
|
|
|
216983
217722
|
config.nodejsscan = { ...config.nodejsscan, enabled: options.nodejsscan !== false };
|
|
216984
217723
|
config.bearer = { ...config.bearer, enabled: options.bearer !== false };
|
|
216985
217724
|
config.semgrep.enabled = options.semgrep !== false;
|
|
217725
|
+
config.trivy = { ...config.trivy, enabled: options.trivy !== false };
|
|
217726
|
+
config.horusec = { ...config.horusec, enabled: options.horusec !== false };
|
|
216986
217727
|
if (!options.quietHeader) {
|
|
216987
217728
|
if (process.stdout.isTTY) {
|
|
216988
217729
|
clearScreen();
|
|
@@ -217029,111 +217770,9 @@ function parseMaxFindings2(raw) {
|
|
|
217029
217770
|
return Number.isFinite(parsed2) && parsed2 > 0 ? Math.floor(parsed2) : Number.POSITIVE_INFINITY;
|
|
217030
217771
|
}
|
|
217031
217772
|
|
|
217032
|
-
// src/commands/setup.ts
|
|
217033
|
-
var import_node_child_process8 = require("child_process");
|
|
217034
|
-
var import_node_util8 = require("util");
|
|
217035
|
-
var execAsync = (0, import_node_util8.promisify)(import_node_child_process8.exec);
|
|
217036
|
-
function getSemgrepInstallCommand(platform) {
|
|
217037
|
-
if (platform === "darwin") return "brew install semgrep";
|
|
217038
|
-
if (platform === "win32") return "choco install semgrep -y";
|
|
217039
|
-
return "python3 -m pip install --user semgrep";
|
|
217040
|
-
}
|
|
217041
|
-
async function setupSemgrepCommand(options = {}) {
|
|
217042
|
-
const installCommand = getSemgrepInstallCommand(process.platform);
|
|
217043
|
-
console.log("Semgrep setup");
|
|
217044
|
-
console.log(`Install command for this system:
|
|
217045
|
-
${installCommand}`);
|
|
217046
|
-
if (!options.auto) {
|
|
217047
|
-
console.log("Run command above, then verify with: semgrep --version");
|
|
217048
|
-
return;
|
|
217049
|
-
}
|
|
217050
|
-
try {
|
|
217051
|
-
console.log("Running installer...");
|
|
217052
|
-
const { stdout, stderr } = await execAsync(installCommand, { timeout: 12e4, maxBuffer: 1024 * 1024 });
|
|
217053
|
-
if (stdout.trim()) console.log(stdout.trim());
|
|
217054
|
-
if (stderr.trim()) console.log(stderr.trim());
|
|
217055
|
-
console.log("Semgrep install command completed. Verify with: semgrep --version");
|
|
217056
|
-
} catch (error) {
|
|
217057
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
217058
|
-
console.error(`Semgrep install failed: ${message}`);
|
|
217059
|
-
process.exitCode = 1;
|
|
217060
|
-
}
|
|
217061
|
-
}
|
|
217062
|
-
function getSetupAllPlan(platform) {
|
|
217063
|
-
return [
|
|
217064
|
-
{
|
|
217065
|
-
name: "ESLint + eslint-plugin-security",
|
|
217066
|
-
includedWithAthena: true,
|
|
217067
|
-
note: "Bundled as Athena optional dependencies and used by the ESLint scanner when present."
|
|
217068
|
-
},
|
|
217069
|
-
{
|
|
217070
|
-
name: "npm audit",
|
|
217071
|
-
includedWithAthena: true,
|
|
217072
|
-
note: "Uses npm CLI that ships with Node.js. No separate scanner package install required."
|
|
217073
|
-
},
|
|
217074
|
-
{
|
|
217075
|
-
name: "Semgrep",
|
|
217076
|
-
includedWithAthena: false,
|
|
217077
|
-
autoInstallCommand: getSemgrepInstallCommand(platform),
|
|
217078
|
-
manualInstallCommand: getSemgrepInstallCommand(platform),
|
|
217079
|
-
note: "External binary scanner. Optional, but improves SAST coverage."
|
|
217080
|
-
},
|
|
217081
|
-
{
|
|
217082
|
-
name: "Docker (for nodejsscan)",
|
|
217083
|
-
includedWithAthena: false,
|
|
217084
|
-
note: "Required runtime for nodejsscan container execution; install from Docker Desktop/package manager."
|
|
217085
|
-
},
|
|
217086
|
-
{
|
|
217087
|
-
name: "Bearer CLI",
|
|
217088
|
-
includedWithAthena: false,
|
|
217089
|
-
autoInstallCommand: "npm install -g @bearer/cli",
|
|
217090
|
-
manualInstallCommand: "npm install -g @bearer/cli",
|
|
217091
|
-
note: "External CLI scanner for privacy and data-flow analysis."
|
|
217092
|
-
}
|
|
217093
|
-
];
|
|
217094
|
-
}
|
|
217095
|
-
async function setupAllCommand(options = {}) {
|
|
217096
|
-
const plan = getSetupAllPlan(process.platform);
|
|
217097
|
-
console.log("Athena scanner setup plan\n");
|
|
217098
|
-
for (const tool of plan) {
|
|
217099
|
-
const inclusion = tool.includedWithAthena ? "included" : "external";
|
|
217100
|
-
console.log(`- ${tool.name} (${inclusion})`);
|
|
217101
|
-
console.log(` ${tool.note}`);
|
|
217102
|
-
if (tool.manualInstallCommand && !tool.includedWithAthena) {
|
|
217103
|
-
console.log(` install: ${tool.manualInstallCommand}`);
|
|
217104
|
-
}
|
|
217105
|
-
}
|
|
217106
|
-
if (!options.auto) {
|
|
217107
|
-
console.log("\nUse --auto to run supported install commands automatically.");
|
|
217108
|
-
return;
|
|
217109
|
-
}
|
|
217110
|
-
let failed = false;
|
|
217111
|
-
for (const tool of plan) {
|
|
217112
|
-
if (!tool.autoInstallCommand) continue;
|
|
217113
|
-
try {
|
|
217114
|
-
console.log(`
|
|
217115
|
-
Installing ${tool.name}...`);
|
|
217116
|
-
const { stdout, stderr } = await execAsync(tool.autoInstallCommand, { timeout: 18e4, maxBuffer: 1024 * 1024 });
|
|
217117
|
-
if (stdout.trim()) console.log(stdout.trim());
|
|
217118
|
-
if (stderr.trim()) console.log(stderr.trim());
|
|
217119
|
-
console.log(`Completed: ${tool.name}`);
|
|
217120
|
-
} catch (error) {
|
|
217121
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
217122
|
-
console.error(`Failed: ${tool.name} (${message})`);
|
|
217123
|
-
failed = true;
|
|
217124
|
-
}
|
|
217125
|
-
}
|
|
217126
|
-
if (failed) {
|
|
217127
|
-
console.log("\nSome installs failed. You can run their manual commands from the setup plan above.");
|
|
217128
|
-
process.exitCode = 1;
|
|
217129
|
-
return;
|
|
217130
|
-
}
|
|
217131
|
-
console.log("\nSetup complete. Run `athena doctor` to verify tool availability.");
|
|
217132
|
-
}
|
|
217133
|
-
|
|
217134
217773
|
// src/commands/uninstall.ts
|
|
217135
|
-
var
|
|
217136
|
-
var
|
|
217774
|
+
var import_promises9 = require("fs/promises");
|
|
217775
|
+
var import_node_path15 = require("path");
|
|
217137
217776
|
async function uninstallCommand() {
|
|
217138
217777
|
const root = await getGitRoot();
|
|
217139
217778
|
const hooksDir = await getGitHooksDir();
|
|
@@ -217142,15 +217781,15 @@ async function uninstallCommand() {
|
|
|
217142
217781
|
process.exitCode = 1;
|
|
217143
217782
|
return;
|
|
217144
217783
|
}
|
|
217145
|
-
const hookPath = (0,
|
|
217146
|
-
await (0,
|
|
217784
|
+
const hookPath = (0, import_node_path15.join)(hooksDir, "pre-commit");
|
|
217785
|
+
await (0, import_promises9.rm)(hookPath, { force: true });
|
|
217147
217786
|
console.log(`Athena pre-commit hook removed from ${hookPath}`);
|
|
217148
217787
|
}
|
|
217149
217788
|
|
|
217150
217789
|
// package.json
|
|
217151
217790
|
var package_default = {
|
|
217152
217791
|
name: "@arsh342/athena",
|
|
217153
|
-
version: "0.2.
|
|
217792
|
+
version: "0.2.5",
|
|
217154
217793
|
description: "AI code provenance tracker and terminal scanner for JavaScript and TypeScript repositories.",
|
|
217155
217794
|
type: "module",
|
|
217156
217795
|
bin: {
|
|
@@ -217304,7 +217943,7 @@ async function select(items) {
|
|
|
217304
217943
|
process.stdin.resume();
|
|
217305
217944
|
let index = 0;
|
|
217306
217945
|
render(items, index, historyText);
|
|
217307
|
-
return new Promise((
|
|
217946
|
+
return new Promise((resolve10) => {
|
|
217308
217947
|
const cleanup = () => {
|
|
217309
217948
|
process.stdin.setRawMode(false);
|
|
217310
217949
|
process.stdin.pause();
|
|
@@ -217312,7 +217951,7 @@ async function select(items) {
|
|
|
217312
217951
|
};
|
|
217313
217952
|
const done = (value) => {
|
|
217314
217953
|
cleanup();
|
|
217315
|
-
|
|
217954
|
+
resolve10(value);
|
|
217316
217955
|
};
|
|
217317
217956
|
const onKeypress = (_input, key) => {
|
|
217318
217957
|
if (key.ctrl && key.name === "c") done(null);
|
|
@@ -217384,7 +218023,7 @@ async function waitForReturnToMenu() {
|
|
|
217384
218023
|
(0, import_node_readline.emitKeypressEvents)(process.stdin);
|
|
217385
218024
|
process.stdin.setRawMode(true);
|
|
217386
218025
|
process.stdin.resume();
|
|
217387
|
-
await new Promise((
|
|
218026
|
+
await new Promise((resolve10) => {
|
|
217388
218027
|
const cleanup = () => {
|
|
217389
218028
|
process.stdin.setRawMode(false);
|
|
217390
218029
|
process.stdin.pause();
|
|
@@ -217392,7 +218031,7 @@ async function waitForReturnToMenu() {
|
|
|
217392
218031
|
};
|
|
217393
218032
|
const onKeypress = () => {
|
|
217394
218033
|
cleanup();
|
|
217395
|
-
|
|
218034
|
+
resolve10();
|
|
217396
218035
|
};
|
|
217397
218036
|
process.stdin.on("keypress", onKeypress);
|
|
217398
218037
|
});
|
|
@@ -217401,11 +218040,11 @@ async function waitForReturnToMenu() {
|
|
|
217401
218040
|
// src/index.ts
|
|
217402
218041
|
var program2 = new Command();
|
|
217403
218042
|
program2.name("athena").description("AI code provenance tracker for JavaScript and TypeScript repositories").version(CLI_VERSION);
|
|
217404
|
-
program2.command("scan").argument("[dir]", "directory to scan", ".").option("-t, --threshold <number>", "AI score threshold", "9").option("-f, --format <format>", "terminal | json | jsonl", "terminal").option("-m, --max-findings <number|all>", "max findings to print (default: all)", "all").option("--no-eslint", "disable ESLint scanner").option("--no-npm-audit", "disable npm audit scanner").option("--no-nodejsscan", "disable nodejsscan scanner").option("--no-bearer", "disable Bearer scanner").option("--no-semgrep", "disable Semgrep scanner").description("scan a directory recursively").action(scanCommand);
|
|
217405
|
-
program2.command("check").argument("[files...]", "files to check; defaults to staged JS/TS files").option("-t, --threshold <number>", "AI score threshold", "9").option("-f, --format <format>", "terminal | json | jsonl", "terminal").option("-m, --max-findings <number|all>", "max findings to print (default: all)", "all").option("--no-eslint", "disable ESLint scanner").option("--no-npm-audit", "disable npm audit scanner").option("--no-nodejsscan", "disable nodejsscan scanner").option("--no-bearer", "disable Bearer scanner").option("--no-semgrep", "disable Semgrep scanner").description("check changed files for blocking findings").action(checkCommand);
|
|
218043
|
+
program2.command("scan").argument("[dir]", "directory to scan", ".").option("-t, --threshold <number>", "AI score threshold", "9").option("-f, --format <format>", "terminal | json | jsonl", "terminal").option("-m, --max-findings <number|all>", "max findings to print (default: all)", "all").option("--no-eslint", "disable ESLint scanner").option("--no-npm-audit", "disable npm audit scanner").option("--no-nodejsscan", "disable nodejsscan scanner").option("--no-bearer", "disable Bearer scanner").option("--no-semgrep", "disable Semgrep scanner").option("--no-trivy", "disable Trivy scanner").option("--no-horusec", "disable Horusec scanner").description("scan a directory recursively").action(scanCommand);
|
|
218044
|
+
program2.command("check").argument("[files...]", "files to check; defaults to staged JS/TS files").option("-t, --threshold <number>", "AI score threshold", "9").option("-f, --format <format>", "terminal | json | jsonl", "terminal").option("-m, --max-findings <number|all>", "max findings to print (default: all)", "all").option("--no-eslint", "disable ESLint scanner").option("--no-npm-audit", "disable npm audit scanner").option("--no-nodejsscan", "disable nodejsscan scanner").option("--no-bearer", "disable Bearer scanner").option("--no-semgrep", "disable Semgrep scanner").option("--no-trivy", "disable Trivy scanner").option("--no-horusec", "disable Horusec scanner").description("check changed files for blocking findings").action(checkCommand);
|
|
217406
218045
|
program2.command("init").description("install Athena pre-commit hook").action(initCommand);
|
|
217407
218046
|
program2.command("uninstall").description("remove Athena pre-commit hook").action(uninstallCommand);
|
|
217408
|
-
program2.command("doctor").description("check local toolchain health
|
|
218047
|
+
program2.command("doctor").option("--fix", "auto-install supported missing external tools").description("check local toolchain health and optionally auto-fix missing scanners").action(doctorCommand);
|
|
217409
218048
|
var setupCommand = program2.command("setup").description("setup optional external scanners");
|
|
217410
218049
|
setupCommand.command("semgrep").option("--auto", "run install command automatically").description("install or print install command for semgrep").action(setupSemgrepCommand);
|
|
217411
218050
|
setupCommand.command("all").option("--auto", "run supported install commands automatically").description("print/setup all scanner dependencies (included + external)").action(setupAllCommand);
|