-
-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Electronegativity plugin (#1900)
- Loading branch information
Showing
5 changed files
with
578 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "@electron-forge/plugin-electronegativity", | ||
"version": "6.0.0-beta.52", | ||
"description": "Integrate Electronegativity into the Electron Forge workflow", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/electron-userland/electron-forge", | ||
"directory": "packages/plugin/electronegativity" | ||
}, | ||
"author": "Mark Lee", | ||
"license": "MIT", | ||
"main": "dist/ElectronegativityPlugin.js", | ||
"typings": "dist/ElectronegativityPlugin.d.ts", | ||
"engines": { | ||
"node": ">= 10.0.0" | ||
}, | ||
"dependencies": { | ||
"@doyensec/electronegativity": "^1.6.0", | ||
"@electron-forge/plugin-base": "6.0.0-beta.52", | ||
"@electron-forge/shared-types": "6.0.0-beta.52" | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
packages/plugin/electronegativity/src/ElectronegativityPlugin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { ForgeConfig } from '@electron-forge/shared-types'; | ||
import PluginBase from '@electron-forge/plugin-base'; | ||
import runElectronegativity from '@doyensec/electronegativity'; | ||
|
||
// To be more precise, postPackage options we care about. | ||
type PostPackageOptions = { | ||
outputPaths: string[]; | ||
}; | ||
|
||
export type Confidence = 'certain' | 'firm' | 'tentative'; | ||
export type CustomCheck = 'dangerousfunctionsjscheck' | 'remotemodulejscheck'; | ||
export type Severity = 'high' | 'medium' | 'low' | 'informational'; | ||
|
||
export type ElectronegativityConfig = { | ||
/** | ||
* Save the results to a file in CSV or SARIF format. | ||
*/ | ||
output?: string; | ||
/** | ||
* Whether to save the output in SARIF or CSV format. | ||
* | ||
* Defaults to CSV. | ||
*/ | ||
isSarif?: boolean; | ||
/** | ||
* Specified checks to run. | ||
*/ | ||
customScan?: CustomCheck[]; | ||
/** | ||
* Only return findings with the specified level of severity or above. | ||
* | ||
* Defaults to `informational`. | ||
*/ | ||
severitySet?: Severity; | ||
/** | ||
* Only return findings with the specified level of confidence or above. | ||
* | ||
* Defaults to `tentative`. | ||
*/ | ||
confidenceSet?: Confidence; | ||
/** | ||
* Whether to show relative paths for files. | ||
* | ||
* Defaults to `false`. | ||
*/ | ||
isRelative?: false; | ||
/** | ||
* Specify a range to run Electron upgrade checks. For example, `'7..8'` checks an upgrade | ||
* from Electron 7 to Electron 8. | ||
*/ | ||
electronUpgrade?: string; | ||
}; | ||
|
||
export default class ElectronegativityPlugin extends PluginBase<ElectronegativityConfig> { | ||
name = 'electronegativity'; | ||
|
||
getHook(hookName: string) { | ||
if (hookName === 'postPackage') { | ||
return this.postPackage; | ||
} | ||
return null; | ||
} | ||
|
||
postPackage = async (_forgeConfig: ForgeConfig, options: PostPackageOptions) => { | ||
await runElectronegativity({ | ||
// FIXME: remove after https://github.com/doyensec/electronegativity/pull/73 is released. | ||
customScan: [], | ||
...this.config, | ||
input: options.outputPaths[0], | ||
}, true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module '@doyensec/electronegativity'; |
Oops, something went wrong.