Merge pull request #159 from github/rename_cli
Rename CLI to CodeQL runner
This commit is contained in:
commit
aac5eb2aea
23 changed files with 56 additions and 56 deletions
|
|
@ -1,4 +1,4 @@
|
|||
name: "CodeScanning CLI"
|
||||
name: "CodeQL runner"
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
|
|
@ -9,15 +9,15 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Build CLI
|
||||
- name: Build runner
|
||||
run: |
|
||||
cd packaging
|
||||
cd runner
|
||||
npm install
|
||||
npm run build-cli
|
||||
npm run build-runner
|
||||
|
||||
- name: Upload with CLI
|
||||
- name: Upload with runner
|
||||
run: |
|
||||
packaging/dist/code-scanning-cli-linux upload \
|
||||
runner/dist/codeql-runner-linux upload \
|
||||
--sarif-file src/testdata/empty-sarif.sarif \
|
||||
--repository $GITHUB_REPOSITORY \
|
||||
--commit $GITHUB_SHA \
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -1,2 +1,2 @@
|
|||
/packaging/dist/
|
||||
/packaging/node_modules/
|
||||
/runner/dist/
|
||||
/runner/node_modules/
|
||||
|
|
|
|||
|
|
@ -49,9 +49,9 @@ Running locally will generate the CodeQL database and run all the queries, but i
|
|||
|
||||
As well as the unit tests (see _Common tasks_ above), there are integration tests, defined in `.github/workflows/integration-testing.yml`. These are run by a CI check. Depending on the change you’re making, you may want to add a test to this file or extend an existing one.
|
||||
|
||||
### Building the CLI
|
||||
### Building the CodeQL runner
|
||||
|
||||
Navigate to the `packaging` directory and run `npm install` to install dependencies needed only for compiling the CLI. Run `npm run build-cli` to output files to the `packaging/dist` directory.
|
||||
Navigate to the `runner` directory and run `npm install` to install dependencies needed only for compiling the CodeQL runner. Run `npm run build-runner` to output files to the `runner/dist` directory.
|
||||
|
||||
## Submitting a pull request
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yCAAoC;AACpC,2CAA6B;AAE7B,uCAAyC;AACzC,6CAAkD;AAClD,yDAA2C;AAE3C,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAC9B,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAYzB,SAAS,iBAAiB,CAAC,QAAgB;IACzC,IAAI;QACF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;QAE9B,kDAAkD;QAClD,0CAA0C;QAC1C,IAAI,GAAG,CAAC,QAAQ,KAAK,YAAY,IAAI,GAAG,CAAC,QAAQ,KAAK,gBAAgB,EAAE;YACtE,OAAO,wBAAwB,CAAC;SACjC;QAED,gDAAgD;QAChD,IAAI,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE;YAC1C,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;SACrD;QAED,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;KAEvB;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,IAAI,QAAQ,sBAAsB,CAAC,CAAC;KACrD;AACH,CAAC;AAED,MAAM,MAAM,GAAG,sBAAY,EAAE,CAAC;AAE9B,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,6EAA6E,CAAC;KAC1F,cAAc,CAAC,qBAAqB,EAAE,sEAAsE,CAAC;KAC7G,cAAc,CAAC,2BAA2B,EAAE,iBAAiB,CAAC;KAC9D,cAAc,CAAC,mBAAmB,EAAE,iCAAiC,CAAC;KACtE,cAAc,CAAC,aAAa,EAAE,+BAA+B,CAAC;KAC9D,cAAc,CAAC,oBAAoB,EAAE,wBAAwB,CAAC;KAC9D,cAAc,CAAC,sBAAsB,EAAE,qFAAqF,CAAC;KAC7H,MAAM,CAAC,wBAAwB,EAAE,oDAAoD,CAAC;KACtF,MAAM,CAAC,KAAK,EAAE,GAAe,EAAE,EAAE;IAChC,IAAI;QACF,MAAM,UAAU,CAAC,MAAM,CACrB,GAAG,CAAC,SAAS,EACb,+BAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,EAClC,GAAG,CAAC,MAAM,EACV,GAAG,CAAC,GAAG,EACP,SAAS,EACT,SAAS,EACT,SAAS,EACT,GAAG,CAAC,YAAY,IAAI,OAAO,CAAC,GAAG,EAAE,EACjC,SAAS,EACT,GAAG,CAAC,UAAU,EACd,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,EAChC,KAAK,EACL,MAAM,CAAC,CAAC;KACX;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAC9B,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAChB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;KACtB;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
||||
6
lib/fingerprints.test.js
generated
6
lib/fingerprints.test.js
generated
|
|
@ -99,7 +99,7 @@ ava_1.default('hash', (t) => {
|
|||
function testResolveUriToFile(uri, index, artifactsURIs) {
|
||||
const location = { "uri": uri, "index": index };
|
||||
const artifacts = artifactsURIs.map(uri => ({ "location": { "uri": uri } }));
|
||||
return fingerprints.resolveUriToFile(location, artifacts, logging_1.getCLILogger());
|
||||
return fingerprints.resolveUriToFile(location, artifacts, logging_1.getRunnerLogger());
|
||||
}
|
||||
ava_1.default('resolveUriToFile', t => {
|
||||
// The resolveUriToFile method checks that the file exists and is in the right directory
|
||||
|
|
@ -144,7 +144,7 @@ ava_1.default('addFingerprints', t => {
|
|||
expected = JSON.stringify(JSON.parse(expected));
|
||||
// The URIs in the SARIF files resolve to files in the testdata directory
|
||||
process.env['GITHUB_WORKSPACE'] = path.normalize(__dirname + '/../src/testdata');
|
||||
t.deepEqual(fingerprints.addFingerprints(input, logging_1.getCLILogger()), expected);
|
||||
t.deepEqual(fingerprints.addFingerprints(input, logging_1.getRunnerLogger()), expected);
|
||||
});
|
||||
ava_1.default('missingRegions', t => {
|
||||
// Run an end-to-end test on a test file
|
||||
|
|
@ -155,6 +155,6 @@ ava_1.default('missingRegions', t => {
|
|||
expected = JSON.stringify(JSON.parse(expected));
|
||||
// The URIs in the SARIF files resolve to files in the testdata directory
|
||||
process.env['GITHUB_WORKSPACE'] = path.normalize(__dirname + '/../src/testdata');
|
||||
t.deepEqual(fingerprints.addFingerprints(input, logging_1.getCLILogger()), expected);
|
||||
t.deepEqual(fingerprints.addFingerprints(input, logging_1.getRunnerLogger()), expected);
|
||||
});
|
||||
//# sourceMappingURL=fingerprints.test.js.map
|
||||
File diff suppressed because one or more lines are too long
4
lib/logging.js
generated
4
lib/logging.js
generated
|
|
@ -12,7 +12,7 @@ function getActionsLogger() {
|
|||
return core;
|
||||
}
|
||||
exports.getActionsLogger = getActionsLogger;
|
||||
function getCLILogger() {
|
||||
function getRunnerLogger() {
|
||||
return {
|
||||
debug: console.debug,
|
||||
info: console.info,
|
||||
|
|
@ -22,5 +22,5 @@ function getCLILogger() {
|
|||
endGroup: () => undefined,
|
||||
};
|
||||
}
|
||||
exports.getCLILogger = getCLILogger;
|
||||
exports.getRunnerLogger = getRunnerLogger;
|
||||
//# sourceMappingURL=logging.js.map
|
||||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAYtC,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC;AAFD,4CAEC;AAED,SAAgB,YAAY;IAC1B,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,UAAU,EAAE,GAAG,EAAE,CAAC,SAAS;QAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS;KAC1B,CAAC;AACJ,CAAC;AATD,oCASC"}
|
||||
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAYtC,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC;AAFD,4CAEC;AAED,SAAgB,eAAe;IAC7B,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,UAAU,EAAE,GAAG,EAAE,CAAC,SAAS;QAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS;KAC1B,CAAC;AACJ,CAAC;AATD,0CASC"}
|
||||
6
lib/cli.js → lib/runner.js
generated
6
lib/cli.js → lib/runner.js
generated
|
|
@ -32,7 +32,7 @@ function parseGithubApiUrl(inputUrl) {
|
|||
throw new Error(`"${inputUrl}" is not a valid URL`);
|
||||
}
|
||||
}
|
||||
const logger = logging_1.getCLILogger();
|
||||
const logger = logging_1.getRunnerLogger();
|
||||
program
|
||||
.command('upload')
|
||||
.description('Uploads a SARIF file, or all SARIF files from a directory, to code scanning')
|
||||
|
|
@ -45,7 +45,7 @@ program
|
|||
.option('--checkout-path <path>', 'Checkout path (default: current working directory)')
|
||||
.action(async (cmd) => {
|
||||
try {
|
||||
await upload_lib.upload(cmd.sarifFile, repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, cmd.ref, undefined, undefined, undefined, cmd.checkoutPath || process.cwd(), undefined, cmd.githubAuth, parseGithubApiUrl(cmd.githubUrl), 'cli', logger);
|
||||
await upload_lib.upload(cmd.sarifFile, repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, cmd.ref, undefined, undefined, undefined, cmd.checkoutPath || process.cwd(), undefined, cmd.githubAuth, parseGithubApiUrl(cmd.githubUrl), 'runner', logger);
|
||||
}
|
||||
catch (e) {
|
||||
logger.error('Upload failed');
|
||||
|
|
@ -54,4 +54,4 @@ program
|
|||
}
|
||||
});
|
||||
program.parse(process.argv);
|
||||
//# sourceMappingURL=cli.js.map
|
||||
//# sourceMappingURL=runner.js.map
|
||||
1
lib/runner.js.map
Normal file
1
lib/runner.js.map
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yCAAoC;AACpC,2CAA6B;AAE7B,uCAA4C;AAC5C,6CAAkD;AAClD,yDAA2C;AAE3C,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAC9B,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAYzB,SAAS,iBAAiB,CAAC,QAAgB;IACzC,IAAI;QACF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;QAE9B,kDAAkD;QAClD,0CAA0C;QAC1C,IAAI,GAAG,CAAC,QAAQ,KAAK,YAAY,IAAI,GAAG,CAAC,QAAQ,KAAK,gBAAgB,EAAE;YACtE,OAAO,wBAAwB,CAAC;SACjC;QAED,gDAAgD;QAChD,IAAI,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE;YAC1C,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;SACrD;QAED,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;KAEvB;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,IAAI,QAAQ,sBAAsB,CAAC,CAAC;KACrD;AACH,CAAC;AAED,MAAM,MAAM,GAAG,yBAAe,EAAE,CAAC;AAEjC,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,6EAA6E,CAAC;KAC1F,cAAc,CAAC,qBAAqB,EAAE,sEAAsE,CAAC;KAC7G,cAAc,CAAC,2BAA2B,EAAE,iBAAiB,CAAC;KAC9D,cAAc,CAAC,mBAAmB,EAAE,iCAAiC,CAAC;KACtE,cAAc,CAAC,aAAa,EAAE,+BAA+B,CAAC;KAC9D,cAAc,CAAC,oBAAoB,EAAE,wBAAwB,CAAC;KAC9D,cAAc,CAAC,sBAAsB,EAAE,qFAAqF,CAAC;KAC7H,MAAM,CAAC,wBAAwB,EAAE,oDAAoD,CAAC;KACtF,MAAM,CAAC,KAAK,EAAE,GAAe,EAAE,EAAE;IAChC,IAAI;QACF,MAAM,UAAU,CAAC,MAAM,CACrB,GAAG,CAAC,SAAS,EACb,+BAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,EAClC,GAAG,CAAC,MAAM,EACV,GAAG,CAAC,GAAG,EACP,SAAS,EACT,SAAS,EACT,SAAS,EACT,GAAG,CAAC,YAAY,IAAI,OAAO,CAAC,GAAG,EAAE,EACjC,SAAS,EACT,GAAG,CAAC,UAAU,EACd,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,EAChC,QAAQ,EACR,MAAM,CAAC,CAAC;KACX;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAC9B,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAChB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;KACtB;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
||||
2
lib/upload-lib.js
generated
2
lib/upload-lib.js
generated
|
|
@ -154,7 +154,7 @@ exports.validateSarifFileSchema = validateSarifFileSchema;
|
|||
async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKey, analysisName, workflowRunID, checkoutPath, environment, githubAuth, githubApiUrl, mode, logger) {
|
||||
logger.info("Uploading sarif files: " + JSON.stringify(sarifFiles));
|
||||
if (mode === 'actions') {
|
||||
// This check only works on actions as env vars don't persist between calls to the CLI
|
||||
// This check only works on actions as env vars don't persist between calls to the runner
|
||||
const sentinelEnvVar = "CODEQL_UPLOAD_SARIF";
|
||||
if (process.env[sentinelEnvVar]) {
|
||||
throw new Error("Aborting upload: only one run of the codeql/analyze or codeql/upload-sarif actions is allowed per job");
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
4
lib/upload-lib.test.js
generated
4
lib/upload-lib.test.js
generated
|
|
@ -17,10 +17,10 @@ const uploadLib = __importStar(require("./upload-lib"));
|
|||
testing_utils_1.setupTests(ava_1.default);
|
||||
ava_1.default('validateSarifFileSchema - valid', t => {
|
||||
const inputFile = __dirname + '/../src/testdata/valid-sarif.sarif';
|
||||
t.notThrows(() => uploadLib.validateSarifFileSchema(inputFile, logging_1.getCLILogger()));
|
||||
t.notThrows(() => uploadLib.validateSarifFileSchema(inputFile, logging_1.getRunnerLogger()));
|
||||
});
|
||||
ava_1.default('validateSarifFileSchema - invalid', t => {
|
||||
const inputFile = __dirname + '/../src/testdata/invalid-sarif.sarif';
|
||||
t.throws(() => uploadLib.validateSarifFileSchema(inputFile, logging_1.getCLILogger()));
|
||||
t.throws(() => uploadLib.validateSarifFileSchema(inputFile, logging_1.getRunnerLogger()));
|
||||
});
|
||||
//# sourceMappingURL=upload-lib.test.js.map
|
||||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"upload-lib.test.js","sourceRoot":"","sources":["../src/upload-lib.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAAuB;AAEvB,uCAAyC;AACzC,mDAA2C;AAC3C,wDAA0C;AAE1C,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,iCAAiC,EAAE,CAAC,CAAC,EAAE;IAC1C,MAAM,SAAS,GAAG,SAAS,GAAG,oCAAoC,CAAC;IACnE,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,uBAAuB,CAAC,SAAS,EAAE,sBAAY,EAAE,CAAC,CAAC,CAAC;AAClF,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,mCAAmC,EAAE,CAAC,CAAC,EAAE;IAC5C,MAAM,SAAS,GAAG,SAAS,GAAG,sCAAsC,CAAC;IACrE,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,uBAAuB,CAAC,SAAS,EAAE,sBAAY,EAAE,CAAC,CAAC,CAAC;AAC/E,CAAC,CAAC,CAAC"}
|
||||
{"version":3,"file":"upload-lib.test.js","sourceRoot":"","sources":["../src/upload-lib.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAAuB;AAEvB,uCAA4C;AAC5C,mDAA2C;AAC3C,wDAA0C;AAE1C,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,iCAAiC,EAAE,CAAC,CAAC,EAAE;IAC1C,MAAM,SAAS,GAAG,SAAS,GAAG,oCAAoC,CAAC;IACnE,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,uBAAuB,CAAC,SAAS,EAAE,yBAAe,EAAE,CAAC,CAAC,CAAC;AACrF,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,mCAAmC,EAAE,CAAC,CAAC,EAAE;IAC5C,MAAM,SAAS,GAAG,SAAS,GAAG,sCAAsC,CAAC;IACrE,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,uBAAuB,CAAC,SAAS,EAAE,yBAAe,EAAE,CAAC,CAAC,CAAC;AAClF,CAAC,CAAC,CAAC"}
|
||||
|
|
@ -27,21 +27,21 @@ class ActionsLibImport extends ImportDeclaration {
|
|||
}
|
||||
|
||||
/**
|
||||
* An entrypoint to the CLI.
|
||||
* An entrypoint to the CodeQL runner.
|
||||
*/
|
||||
class ClIEntrypoint extends Function {
|
||||
ClIEntrypoint() {
|
||||
getFile().getAbsolutePath().matches("%/cli.ts")
|
||||
class RunnerEntrypoint extends Function {
|
||||
RunnerEntrypoint() {
|
||||
getFile().getAbsolutePath().matches("%/runner.ts")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A check of whether we are in actions mode or CLI mode.
|
||||
* A check of whether we are in actions mode or runner mode.
|
||||
*/
|
||||
class ModeGuard extends IfStmt {
|
||||
ModeGuard() {
|
||||
getCondition().(EqualityTest).getAnOperand().(StringLiteral).getValue() = "actions" or
|
||||
getCondition().(EqualityTest).getAnOperand().(StringLiteral).getValue() = "cli"
|
||||
getCondition().(EqualityTest).getAnOperand().(StringLiteral).getValue() = "runner"
|
||||
}
|
||||
|
||||
string getOperand() {
|
||||
|
|
@ -58,11 +58,11 @@ class ModeGuard extends IfStmt {
|
|||
Stmt getActionsBlock() {
|
||||
(getOperand() = "actions" and isPositive() and result = getThen())
|
||||
or
|
||||
(getOperand() = "cli" and not isPositive() and result = getThen())
|
||||
(getOperand() = "runner" and not isPositive() and result = getThen())
|
||||
or
|
||||
(getOperand() = "actions" and not isPositive() and result = getElse())
|
||||
or
|
||||
(getOperand() = "cli" and isPositive() and result = getElse())
|
||||
(getOperand() = "runner" and isPositive() and result = getElse())
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -99,10 +99,10 @@ Function calledBy(Function f) {
|
|||
not exists(ModeGuard guard | guard.getAnActionsExpr() = result))
|
||||
}
|
||||
|
||||
from VarAccess v, ActionsLibImport actionsLib, ClIEntrypoint cliEntry
|
||||
from VarAccess v, ActionsLibImport actionsLib, RunnerEntrypoint runnerEntry
|
||||
where actionsLib.getAProvidedVariable() = v.getVariable()
|
||||
and getAFunctionChildExpr(calledBy*(cliEntry)) = v
|
||||
and getAFunctionChildExpr(calledBy*(runnerEntry)) = v
|
||||
select v, "$@ is imported from $@ and this code can be called from $@",
|
||||
v, v.getName(),
|
||||
actionsLib, actionsLib.getName(),
|
||||
cliEntry, "the CLI"
|
||||
runnerEntry, "the runner"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "codeql-packaging",
|
||||
"name": "codeql-runner",
|
||||
"version": "0.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
{
|
||||
"name": "codeql-packaging",
|
||||
"name": "codeql-runner",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"description": "CodeQL action - CLI packaging",
|
||||
"description": "CodeQL runner",
|
||||
"scripts": {
|
||||
"build-cli": "webpack --mode production && pkg dist/code-scanning-cli.js --out-path dist"
|
||||
"build-runner": "webpack --mode production && pkg dist/codeql-runner.js --out-path dist"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {},
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
entry: '../src/cli.ts',
|
||||
entry: '../src/runner.ts',
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
|
|
@ -16,7 +16,7 @@ module.exports = {
|
|||
extensions: [ '.ts', '.js' ],
|
||||
},
|
||||
output: {
|
||||
filename: 'code-scanning-cli.js',
|
||||
filename: 'codeql-runner.js',
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
},
|
||||
optimization: {
|
||||
|
|
@ -4,7 +4,7 @@ import * as fs from 'fs';
|
|||
import * as path from 'path';
|
||||
|
||||
import * as fingerprints from './fingerprints';
|
||||
import { getCLILogger } from './logging';
|
||||
import { getRunnerLogger } from './logging';
|
||||
import {setupTests} from './testing-utils';
|
||||
|
||||
setupTests(test);
|
||||
|
|
@ -116,7 +116,7 @@ test('hash', (t: ava.Assertions) => {
|
|||
function testResolveUriToFile(uri: any, index: any, artifactsURIs: any[]) {
|
||||
const location = { "uri": uri, "index": index };
|
||||
const artifacts = artifactsURIs.map(uri => ({ "location": { "uri": uri } }));
|
||||
return fingerprints.resolveUriToFile(location, artifacts, getCLILogger());
|
||||
return fingerprints.resolveUriToFile(location, artifacts, getRunnerLogger());
|
||||
}
|
||||
|
||||
test('resolveUriToFile', t => {
|
||||
|
|
@ -175,7 +175,7 @@ test('addFingerprints', t => {
|
|||
// The URIs in the SARIF files resolve to files in the testdata directory
|
||||
process.env['GITHUB_WORKSPACE'] = path.normalize(__dirname + '/../src/testdata');
|
||||
|
||||
t.deepEqual(fingerprints.addFingerprints(input, getCLILogger()), expected);
|
||||
t.deepEqual(fingerprints.addFingerprints(input, getRunnerLogger()), expected);
|
||||
});
|
||||
|
||||
test('missingRegions', t => {
|
||||
|
|
@ -190,5 +190,5 @@ test('missingRegions', t => {
|
|||
// The URIs in the SARIF files resolve to files in the testdata directory
|
||||
process.env['GITHUB_WORKSPACE'] = path.normalize(__dirname + '/../src/testdata');
|
||||
|
||||
t.deepEqual(fingerprints.addFingerprints(input, getCLILogger()), expected);
|
||||
t.deepEqual(fingerprints.addFingerprints(input, getRunnerLogger()), expected);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export function getActionsLogger(): Logger {
|
|||
return core;
|
||||
}
|
||||
|
||||
export function getCLILogger(): Logger {
|
||||
export function getRunnerLogger(): Logger {
|
||||
return {
|
||||
debug: console.debug,
|
||||
info: console.info,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Command } from 'commander';
|
||||
import * as path from 'path';
|
||||
|
||||
import { getCLILogger } from './logging';
|
||||
import { getRunnerLogger } from './logging';
|
||||
import { parseRepositoryNwo } from './repository';
|
||||
import * as upload_lib from './upload-lib';
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ function parseGithubApiUrl(inputUrl: string): string {
|
|||
}
|
||||
}
|
||||
|
||||
const logger = getCLILogger();
|
||||
const logger = getRunnerLogger();
|
||||
|
||||
program
|
||||
.command('upload')
|
||||
|
|
@ -66,7 +66,7 @@ program
|
|||
undefined,
|
||||
cmd.githubAuth,
|
||||
parseGithubApiUrl(cmd.githubUrl),
|
||||
'cli',
|
||||
'runner',
|
||||
logger);
|
||||
} catch (e) {
|
||||
logger.error('Upload failed');
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import test from 'ava';
|
||||
|
||||
import { getCLILogger } from './logging';
|
||||
import { getRunnerLogger } from './logging';
|
||||
import {setupTests} from './testing-utils';
|
||||
import * as uploadLib from './upload-lib';
|
||||
|
||||
|
|
@ -8,10 +8,10 @@ setupTests(test);
|
|||
|
||||
test('validateSarifFileSchema - valid', t => {
|
||||
const inputFile = __dirname + '/../src/testdata/valid-sarif.sarif';
|
||||
t.notThrows(() => uploadLib.validateSarifFileSchema(inputFile, getCLILogger()));
|
||||
t.notThrows(() => uploadLib.validateSarifFileSchema(inputFile, getRunnerLogger()));
|
||||
});
|
||||
|
||||
test('validateSarifFileSchema - invalid', t => {
|
||||
const inputFile = __dirname + '/../src/testdata/invalid-sarif.sarif';
|
||||
t.throws(() => uploadLib.validateSarifFileSchema(inputFile, getCLILogger()));
|
||||
t.throws(() => uploadLib.validateSarifFileSchema(inputFile, getRunnerLogger()));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import { RepositoryNwo } from './repository';
|
|||
import * as sharedEnv from './shared-environment';
|
||||
import * as util from './util';
|
||||
|
||||
type UploadMode = 'actions' | 'cli';
|
||||
type UploadMode = 'actions' | 'runner';
|
||||
|
||||
// Takes a list of paths to sarif files and combines them together,
|
||||
// returning the contents of the combined sarif file.
|
||||
|
|
@ -221,7 +221,7 @@ async function uploadFiles(
|
|||
logger.info("Uploading sarif files: " + JSON.stringify(sarifFiles));
|
||||
|
||||
if (mode === 'actions') {
|
||||
// This check only works on actions as env vars don't persist between calls to the CLI
|
||||
// This check only works on actions as env vars don't persist between calls to the runner
|
||||
const sentinelEnvVar = "CODEQL_UPLOAD_SARIF";
|
||||
if (process.env[sentinelEnvVar]) {
|
||||
throw new Error("Aborting upload: only one run of the codeql/analyze or codeql/upload-sarif actions is allowed per job");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue