Skip to content

Commit

Permalink
Allow overriding the detected Electron version
Browse files Browse the repository at this point in the history
  • Loading branch information
baltpeter committed Jun 29, 2020
1 parent 3d1beb7 commit 6c864b9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ $ electronegativity -h
| -r, --relative | show relative path for files |
| -v, --verbose | show the description for the findings |
| -u, --upgrade <current version..target version> | run Electron upgrade checks, eg -u 7..8 to check upgrade from Electron 7 to 8 |
| -e, --electron-version <version> | assume the set Electron version, overriding the detected one, eg -e 7.0.0 |
| -h, --help | output usage information |


Expand Down Expand Up @@ -86,7 +87,9 @@ run({
// show relative path for files (optional)
isRelative: false,
// run Electron upgrade checks, eg -u 7..8 to check upgrade from Electron 7 to 8 (optional)
electronUpgrade: '7..8'
electronUpgrade: '7..8',
// assume the set Electron version, overriding the detected one
electronVersion: '5.0.0'
})
.then(result => console.log(result))
.catch(err => console.error(err));
Expand Down
18 changes: 10 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import run from './runner.js';
const VER = require('../package.json').version;

console.log(`
▄▄▄ ▄▄▌ ▄▄▄ .▄▄·▄▄▄▄▄▄▄
▀▄.▀██• ▀▄.▀▐█ ▌•██ ▀▄ █▪
▐▀▀▪██▪ ▐▀▀▪██ ▄▄▐█.▐▀▀▄ ▄█▀▄
▐█▄▄▐█▌▐▐█▄▄▐███▌▐█▌▐█•█▐█▌.▐▌
▀▀▀.▀▀▀ ▀▀▀·▀▀▀ ▀▀▀.▀ ▀▀█▄▀▪
▄▄▄ ▄▄▌ ▄▄▄ .▄▄·▄▄▄▄▄▄▄
▀▄.▀██• ▀▄.▀▐█ ▌•██ ▀▄ █▪
▐▀▀▪██▪ ▐▀▀▪██ ▄▄▐█.▐▀▀▄ ▄█▀▄
▐█▄▄▐█▌▐▐█▄▄▐███▌▐█▌▐█•█▐█▌.▐▌
▀▀▀.▀▀▀ ▀▀▀·▀▀▀ ▀▀▀.▀ ▀▀█▄▀▪
▐ ▄▄▄▄ .▄▄ • ▄▄▄▄▄▄▄▪ ▌ ▐▪▄▄▄▄▄▄· ▄▌
•█▌▐▀▄.▀▐█ ▀ ▐█ ▀•██ ██▪█·██•██ ▐█▪██▌
▐█▐▐▐▀▀▪▄█ ▀█▄█▀▀█▐█.▐█▐█▐█▐█▐█.▐█▌▐█▪
Expand All @@ -33,6 +33,7 @@ program
.option('-r, --relative', 'show relative path for files')
.option('-v, --verbose', 'show the description for the findings')
.option('-u, --upgrade <current version..target version>', 'run Electron upgrade checks, eg -u 7..8')
.option('-e, --electron-version <version>', 'assume the set Electron version, overriding the detected one, eg -e 7.0.0')
.parse(process.argv);

if(!program.input){
Expand Down Expand Up @@ -63,12 +64,13 @@ const forCli = true;

run({
input,
output: program.output,
output: program.output,
isSarif: program.fileFormat === 'sarif',
customScan: program.checks,
severitySet: program.severity,
severitySet: program.severity,
confidenceSet: program.confidence,
isRelative: program.relative,
isVerbose: program.verbose,
electronUpgrade: program.upgrade
electronUpgrade: program.upgrade,
electronVersionOverride: program.electronVersion
}, forCli);
5 changes: 3 additions & 2 deletions src/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export default async function run(options, forCli = false) {
}

await loader.load(options.input);
if (!loader.electron_version)
const electron_version = options.electronVersionOverride || loader.electron_version;
if (!electron_version)
logger.warn("Couldn't detect Electron version, assuming v0.1.0. Defaults have probably changed for your actual version, please check manually.");

if (options.severitySet) {
Expand Down Expand Up @@ -96,7 +97,7 @@ export default async function run(options, forCli = false) {
}
}

const result = await finder.find(file, data, type, content, null, loader.electron_version);
const result = await finder.find(file, data, type, content, null, electron_version);
issues.push(...result);
} catch (error) {
errors.push({ file: file, message: error.message, tolerable: false });
Expand Down

0 comments on commit 6c864b9

Please sign in to comment.