@@ -72,10 +72,14 @@ type RetireJsOutput = {
7272export class RetireJsEngine extends AbstractRuleEngine {
7373 public static ENGINE_ENUM : ENGINE = ENGINE . RETIRE_JS ;
7474 public static ENGINE_NAME : string = ENGINE . RETIRE_JS . valueOf ( ) ;
75- // RetireJS isn't really built to be invoked programmatically, so we'll need to invoke it as a CLI command. However, we
76- // can't assume that they have the module installed globally. So what we're doing here is identifying the path to the
77- // locally-scoped `retire` module, and then using that to derive a path to the CLI-executable JS script.
75+ // RetireJS isn't really built to be invoked programmatically, so we need to invoke it as a CLI command. However, we
76+ // can't assume that the user has `retire` globally installed . So we identify the path to the locally-scoped `retire`
77+ // module, and then use that to derive a path to the CLI-executable JS script.
7878 private static RETIRE_JS_PATH : string = require . resolve ( 'retire' ) . replace ( path . join ( 'lib' , 'retire.js' ) , path . join ( 'bin' , 'retire' ) ) ;
79+ // We also can't assume that the user actually has Node globally installed on their machine. So we need to figure out
80+ // the version of node that's being executed right now (which may or may not be the version bundled with SFDX), so we
81+ // can use that.
82+ private static NODE_EXEC_PATH : string = process . execPath ;
7983 // RetireJS typically loads a JSON of all vulnerabilities from the Github repo. We want to override that, using this
8084 // local path instead.
8185 private static VULN_JSON_PATH : string = require . resolve ( path . join ( '..' , '..' , '..' , 'retire-js' , 'RetireJsVulns.json' ) ) ;
@@ -184,7 +188,7 @@ export class RetireJsEngine extends AbstractRuleEngine {
184188 // So we use --js and --jspath to make retire-js only examine JS files and skip node modules.
185189 // We also hardcode a locally-stored vulnerability repo instead of allowing use of the default one.
186190 invocationArray . push ( {
187- args : [ '--js' , '--jspath' , target , '--outputformat' , 'json' , '--jsrepo' , RetireJsEngine . VULN_JSON_PATH ] ,
191+ args : [ RetireJsEngine . RETIRE_JS_PATH , '--js' , '--jspath' , target , '--outputformat' , 'json' , '--jsrepo' , RetireJsEngine . VULN_JSON_PATH ] ,
188192 rule : rule . name
189193 } ) ;
190194 break ;
@@ -197,7 +201,7 @@ export class RetireJsEngine extends AbstractRuleEngine {
197201
198202 private async executeRetireJs ( invocation : RetireJsInvocation ) : Promise < RuleResult [ ] > {
199203 return new Promise < RuleResult [ ] > ( ( res , rej ) => {
200- const cp = cspawn ( RetireJsEngine . RETIRE_JS_PATH , invocation . args ) ;
204+ const cp = cspawn ( RetireJsEngine . NODE_EXEC_PATH , invocation . args ) ;
201205
202206 // Initialize both stdout and stderr as empty strings to which we can append data as we receive it.
203207 let stdout = '' ;
0 commit comments