Skip to content

Commit

Permalink
Avoid shell interpretation of gpg command (#92)
Browse files Browse the repository at this point in the history
* Avoid shell interpretation of gpg command

This provides the shell command with the arguments separated to avoid
interpretation by the shell.

fixes: https://github.com/codecov/test-results-action/security/code-scanning/3

* Remove unnecessary codeql checks

This is because it's configured already on the repo level.

* Retriggering build
  • Loading branch information
michelletran-codecov authored Oct 9, 2024
1 parent 7c17a47 commit 9739113
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 87 deletions.
69 changes: 0 additions & 69 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

14 changes: 6 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32363,32 +32363,30 @@ const verify = (filename, platform, version, verbose, failCi) => __awaiter(void
}
});
const verifySignature = () => __awaiter(void 0, void 0, void 0, function* () {
const command = [
'gpg',
const args = [
'--logger-fd',
'1',
'--verify',
external_node_path_namespaceObject.join(__dirname, `${uploaderName}.SHA256SUM.sig`),
external_node_path_namespaceObject.join(__dirname, `${uploaderName}.SHA256SUM`),
].join(' ');
];
try {
yield (0,external_node_child_process_namespaceObject.execSync)(command, { stdio: 'inherit' });
yield (0,external_node_child_process_namespaceObject.spawnSync)('gpg', args, { stdio: 'inherit' });
}
catch (err) {
setFailure(`Codecov: Error verifying gpg signature: ${err.message}`, failCi);
}
});
const importKey = () => __awaiter(void 0, void 0, void 0, function* () {
const command = [
'gpg',
const args = [
'--logger-fd',
'1',
'--no-default-keyring',
'--import',
external_node_path_namespaceObject.join(__dirname, 'pgp_keys.asc'),
].join(' ');
];
try {
yield (0,external_node_child_process_namespaceObject.execSync)(command, { stdio: 'inherit' });
yield (0,external_node_child_process_namespaceObject.spawnSync)('gpg', args, { stdio: 'inherit' });
}
catch (err) {
setFailure(`Codecov: Error importing gpg key: ${err.message}`, failCi);
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

16 changes: 7 additions & 9 deletions src/validate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {execSync} from 'node:child_process';
import {spawnSync} from 'node:child_process';
import * as crypto from 'node:crypto';
import * as fs from 'node:fs';
import * as path from 'node:path';
Expand Down Expand Up @@ -77,17 +77,16 @@ const verify = async (
};

const verifySignature = async () => {
const command = [
'gpg',
const args = [
'--logger-fd',
'1',
'--verify',
path.join(__dirname, `${uploaderName}.SHA256SUM.sig`),
path.join(__dirname, `${uploaderName}.SHA256SUM`),
].join(' ');
];

try {
await execSync(command, {stdio: 'inherit'});
await spawnSync('gpg', args, {stdio: 'inherit'});
} catch (err) {
setFailure(
`Codecov: Error verifying gpg signature: ${err.message}`,
Expand All @@ -97,17 +96,16 @@ const verify = async (
};

const importKey = async () => {
const command = [
'gpg',
const args = [
'--logger-fd',
'1',
'--no-default-keyring',
'--import',
path.join(__dirname, 'pgp_keys.asc'),
].join(' ');
];

try {
await execSync(command, {stdio: 'inherit'});
await spawnSync('gpg', args, {stdio: 'inherit'});
} catch (err) {
setFailure(`Codecov: Error importing gpg key: ${err.message}`, failCi);
}
Expand Down

0 comments on commit 9739113

Please sign in to comment.