mirror of
https://github.com/github/codeql-action.git
synced 2025-12-09 01:08:10 +08:00
Compare commits
15 Commits
v2.1.16
...
error-impr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
526f19341b | ||
|
|
ea8c11c723 | ||
|
|
df49e473c8 | ||
|
|
8d49f67955 | ||
|
|
dc2f0c2f5f | ||
|
|
5767c8ebfc | ||
|
|
fde574ae22 | ||
|
|
3b632c3106 | ||
|
|
b63d497b0e | ||
|
|
f1569d58df | ||
|
|
f2c8606b17 | ||
|
|
066d9716c6 | ||
|
|
642850bff5 | ||
|
|
5fa6bd2622 | ||
|
|
278f870907 |
@@ -53,6 +53,6 @@ export function includeAndExcludeAnalysisPaths(config: configUtils.Config, langu
|
|||||||
config.pathsIgnore.length !== 0 ||
|
config.pathsIgnore.length !== 0 ||
|
||||||
filters.length !== 0) &&
|
filters.length !== 0) &&
|
||||||
!languages.every(isInterpretedLanguage)) {
|
!languages.every(isInterpretedLanguage)) {
|
||||||
core.warning('The "paths"/"paths-ignore" fields of the config only have effect for Javascript and Python');
|
core.warning('The "paths"/"paths-ignore" fields of the configuration only effect Javascript and Python analysis. [Learn more](https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#specifying-directories-to-scan) about modifying the directories to scan. );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ async function run() {
|
|||||||
core.endGroup();
|
core.endGroup();
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed("We were unable to automatically build your code. Please replace the call to the autobuild action with your custom build steps. " + error.message);
|
core.setFailed(`We were unable to automatically build your ${language} code. Please replace the call to the autobuild action with your custom build steps. \n` + error.message);
|
||||||
await util.reportActionFailed('autobuild', error.message, error.stack);
|
await util.reportActionFailed('autobuild', error.message, error.stack);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,19 @@ export interface ResolveQueriesOutput {
|
|||||||
[queryPath: string]: {}
|
[queryPath: string]: {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
const options = {
|
||||||
|
ignoreReturnCode: true,
|
||||||
|
failOnStdErr: true,
|
||||||
|
silent:true,
|
||||||
|
listeners: {
|
||||||
|
stdout: (data: Buffer) => {
|
||||||
|
core.debug("Debug" + data.toString());
|
||||||
|
},
|
||||||
|
stderr: (data: Buffer) => {
|
||||||
|
core.error("Error occured" + data.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Environment variable used to store the location of the CodeQL CLI executable.
|
* Environment variable used to store the location of the CodeQL CLI executable.
|
||||||
* Value is set by setupCodeQL and read by getCodeQL.
|
* Value is set by setupCodeQL and read by getCodeQL.
|
||||||
@@ -185,10 +197,14 @@ function getCodeQLForCmd(cmd: string): CodeQL {
|
|||||||
'--language=' + language
|
'--language=' + language
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
silent: true,
|
ignoreReturnCode: true,
|
||||||
listeners: {
|
listeners: {
|
||||||
stdout: (data) => { extractorPath += data.toString(); },
|
stdout: (data: Buffer) => {
|
||||||
stderr: (data) => { process.stderr.write(data); }
|
core.debug("Debug" + data.toString());
|
||||||
|
},
|
||||||
|
stderr: (data: Buffer) => {
|
||||||
|
core.error("Error occured" + data.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -203,14 +219,15 @@ function getCodeQLForCmd(cmd: string): CodeQL {
|
|||||||
databasePath,
|
databasePath,
|
||||||
'--',
|
'--',
|
||||||
traceCommand
|
traceCommand
|
||||||
]);
|
], options);
|
||||||
},
|
},
|
||||||
finalizeDatabase: async function(databasePath: string) {
|
finalizeDatabase: async function(databasePath: string) {
|
||||||
|
core.debug("Finalizing " + databasePath);
|
||||||
await exec.exec(cmd, [
|
await exec.exec(cmd, [
|
||||||
'database',
|
'database',
|
||||||
'finalize',
|
'finalize',
|
||||||
databasePath
|
databasePath
|
||||||
]);
|
], options );
|
||||||
},
|
},
|
||||||
resolveQueries: async function(queries: string[]) {
|
resolveQueries: async function(queries: string[]) {
|
||||||
let output = '';
|
let output = '';
|
||||||
@@ -221,29 +238,22 @@ function getCodeQLForCmd(cmd: string): CodeQL {
|
|||||||
'queries',
|
'queries',
|
||||||
...queries,
|
...queries,
|
||||||
'--format=bylanguage'
|
'--format=bylanguage'
|
||||||
],
|
], options);
|
||||||
{
|
|
||||||
listeners: {
|
|
||||||
stdout: (data: Buffer) => {
|
|
||||||
output += data.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return JSON.parse(output);
|
return JSON.parse(output);
|
||||||
},
|
},
|
||||||
databaseAnalyze: async function(databasePath: string, sarifFile: string, querySuite: string) {
|
databaseAnalyze: async function(databasePath: string, sarifFile: string, querySuite: string) {
|
||||||
await exec.exec(cmd, [
|
await exec.exec(cmd, [
|
||||||
'database',
|
'database',
|
||||||
'analyze',
|
'analyze',
|
||||||
util.getMemoryFlag(),
|
util.getMemoryFlag(),
|
||||||
util.getThreadsFlag(),
|
util.getThreadsFlag(),
|
||||||
databasePath,
|
databasePath,
|
||||||
'--format=sarif-latest',
|
'--format=sarif-latest',
|
||||||
'--output=' + sarifFile,
|
'--output=' + sarifFile,
|
||||||
'--no-sarif-add-snippets',
|
'--no-sarif-add-snippets',
|
||||||
querySuite
|
querySuite
|
||||||
]);
|
], options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,7 +128,16 @@ async function runQueries(databaseFolder: string, sarifFolder: string, config: c
|
|||||||
|
|
||||||
const sarifFile = path.join(sarifFolder, database + '.sarif');
|
const sarifFile = path.join(sarifFolder, database + '.sarif');
|
||||||
|
|
||||||
await codeql.databaseAnalyze(path.join(databaseFolder, database), sarifFile, querySuite);
|
try {
|
||||||
|
await codeql.databaseAnalyze(path.join(databaseFolder, database), sarifFile, querySuite);
|
||||||
|
} catch (analysisError) {
|
||||||
|
core.debug("test test test" + analysisError.message);
|
||||||
|
if (analysisError.message.contains("exit code 32")) {
|
||||||
|
throw new Error('Unable to analyze ' + database + ' because CodeQL was unable to detect any code for that language. \n [Learn more](https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/troubleshooting-code-scanning) about how to troubleshoot this error. ');
|
||||||
|
} else {
|
||||||
|
throw new Error(analysisError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
core.debug('SARIF results for database ' + database + ' created at "' + sarifFile + '"');
|
core.debug('SARIF results for database ' + database + ' created at "' + sarifFile + '"');
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
@@ -136,7 +145,7 @@ async function runQueries(databaseFolder: string, sarifFolder: string, config: c
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
//try {
|
||||||
if (util.should_abort('finish', true) || !await util.reportActionStarting('finish')) {
|
if (util.should_abort('finish', true) || !await util.reportActionStarting('finish')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -165,11 +174,11 @@ async function run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
/*} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
await util.reportActionFailed('finish', error.message, error.stack);
|
await util.reportActionFailed('finish', error.message, error.stack);
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
await util.reportActionSucceeded('finish');
|
await util.reportActionSucceeded('finish');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ async function run() {
|
|||||||
// If the languages parameter was not given and no languages were
|
// If the languages parameter was not given and no languages were
|
||||||
// detected then fail here as this is a workflow configuration error.
|
// detected then fail here as this is a workflow configuration error.
|
||||||
if (languages.length === 0) {
|
if (languages.length === 0) {
|
||||||
throw new Error("Did not detect any languages to analyze. Please update input in workflow.");
|
throw new Error("Did not detect any languages to analyze. Please [update the languages property](https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection) in your workflow definition.");
|
||||||
}
|
}
|
||||||
|
|
||||||
analysisPaths.includeAndExcludeAnalysisPaths(config, languages);
|
analysisPaths.includeAndExcludeAnalysisPaths(config, languages);
|
||||||
@@ -243,6 +243,6 @@ async function run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
run().catch(e => {
|
run().catch(e => {
|
||||||
core.setFailed("init action failed: " + e);
|
core.setFailed("Init action failed: " + e);
|
||||||
console.log(e);
|
console.log(e);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user