Skip to content

Commit

Permalink
NEW (Extension) @W-15639920@ CLI changes to pass java env variable to…
Browse files Browse the repository at this point in the history
… enable caching and path for delta runs
  • Loading branch information
jag-j committed Sep 5, 2024
1 parent fc0d01b commit 1f75111
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/commands/scanner/run/dfa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,17 @@ export default class Dfa extends ScannerRunCommand {
summary: getMessage(BundleName.RunDfa, 'flags.pathexplimitSummary'),
description: getMessage(BundleName.RunDfa, 'flags.pathexplimitDescription'),
env: 'SFGE_PATH_EXPANSION_LIMIT'
})
}),
'enablecaching': Flags.boolean({
summary: '',
description: '',
env: 'SFGE_ENABLE_CACHING'
}),
'cachepath': Flags.string({
summary: '',
description: '',
env: 'SFGE_FILES_TO_ENTRIES_CACHE_LOCATION'
}),
// END: Config-overrideable engine flags.
};

Expand Down
10 changes: 9 additions & 1 deletion src/lib/EngineOptionsFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ abstract class CommonEngineOptionsFactory implements EngineOptionsFactory {
const options: Map<string,string> = new Map();
if (this.shouldSfgeRun(inputs)) {
const sfgeConfig: SfgeConfig = {
projectDirs: this.inputProcessor.resolveProjectDirPaths(inputs)
projectDirs: this.inputProcessor.resolveProjectDirPaths(inputs),
cachepath: inputs.cachepath,
enablecaching: inputs.enablecaching
};
options.set(CUSTOM_CONFIG.SfgeConfig, JSON.stringify(sfgeConfig));
}
Expand Down Expand Up @@ -114,6 +116,12 @@ export class RunDfaEngineOptionsFactory extends CommonEngineOptionsFactory {
if (inputs['pathexplimit'] != null) {
sfgeConfig.pathexplimit = inputs['pathexplimit'] as number;
}
if (inputs['enablecaching'] != null) {
sfgeConfig.enablecaching = inputs['enablecaching'] as boolean;
}
if (inputs['cachepath'] != null) {
sfgeConfig.cachepath = inputs['cachepath'] as string;
}
sfgeConfig.ruleDisableWarningViolation = getBooleanEngineOption(inputs, RULE_DISABLE_WARNING_VIOLATION_FLAG);
engineOptions.set(CUSTOM_CONFIG.SfgeConfig, JSON.stringify(sfgeConfig));

Expand Down
21 changes: 20 additions & 1 deletion src/lib/sfge/SfgeWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ type SfgeWrapperOptions = {
spinnerManager: SpinnerManager;
jvmArgs?: string;
pathExpLimit?: number;
enablecaching?: boolean;
cachepath?: string;
}

type SfgeCatalogOptions = SfgeWrapperOptions & {
Expand All @@ -46,6 +48,8 @@ type SfgeExecuteOptions = SfgeWrapperOptions & {
ruleThreadCount?: number;
ruleThreadTimeout?: number;
ruleDisableWarningViolation?: boolean;
enablecaching?: boolean;
cachepath?: string;
}

type SfgeTarget = {
Expand All @@ -57,6 +61,8 @@ type SfgeInput = {
targets: SfgeTarget[];
projectDirs: string[];
rulesToRun: string[];
enablecaching?: boolean;
cachepath?: string;
};

class SfgeSpinnerManager extends AsyncCreatable implements SpinnerManager {
Expand Down Expand Up @@ -164,6 +170,7 @@ abstract class AbstractSfgeWrapper extends CommandLineSupport {
}
args.push(...this.getSupplementalFlags(), MAIN_CLASS, this.action, ...(await this.getSupplementalArgs()));
this.logger.trace(`Preparing to execute sfge with command: "${command}", args: "${JSON.stringify(args)}"`);
console.log(`Preparing to execute sfge with command: "${command}", args: "${JSON.stringify(args)}"`);
return [command, args];
}
protected async execute(): Promise<string> {
Expand Down Expand Up @@ -209,6 +216,8 @@ export class SfgeExecuteWrapper extends AbstractSfgeWrapper {
private ruleThreadCount: number;
private ruleThreadTimeout: number;
private ruleDisableWarningViolation: boolean;
private enablecaching: boolean;
private cachepath: string;

constructor(options: SfgeExecuteOptions) {
super(options);
Expand All @@ -218,6 +227,8 @@ export class SfgeExecuteWrapper extends AbstractSfgeWrapper {
this.ruleThreadCount = options.ruleThreadCount;
this.ruleThreadTimeout = options.ruleThreadTimeout;
this.ruleDisableWarningViolation = options.ruleDisableWarningViolation;
this.enablecaching = options.enablecaching;
this.cachepath = options.cachepath;
}

protected getSupplementalFlags(): string[] {
Expand All @@ -231,6 +242,12 @@ export class SfgeExecuteWrapper extends AbstractSfgeWrapper {
if (this.ruleDisableWarningViolation != null) {
flags.push(`-DSFGE_RULE_DISABLE_WARNING_VIOLATION=${this.ruleDisableWarningViolation.toString()}`);
}
if (this.enablecaching) {
flags.push(`-DSFGE_DISABLE_CACHING=false`);
}
if (this.cachepath != null) {
flags.push(`-DSFGE_FILES_TO_ENTRIES_CACHE_LOCATION=${this.cachepath}`);
}
return flags;
}

Expand Down Expand Up @@ -291,7 +308,9 @@ export class SfgeExecuteWrapper extends AbstractSfgeWrapper {
pathExpLimit: sfgeConfig.pathexplimit,
ruleThreadCount: sfgeConfig.ruleThreadCount,
ruleThreadTimeout: sfgeConfig.ruleThreadTimeout,
ruleDisableWarningViolation: sfgeConfig.ruleDisableWarningViolation
ruleDisableWarningViolation: sfgeConfig.ruleDisableWarningViolation,
cachepath: sfgeConfig.cachepath,
enablecaching: sfgeConfig.enablecaching
});
return wrapper.execute();
}
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,6 @@ export type SfgeConfig = {
ruleDisableWarningViolation?: boolean;
jvmArgs?: string;
pathexplimit?: number;
enablecaching?: boolean;
cachepath?: string;
};

0 comments on commit 1f75111

Please sign in to comment.