Skip to content

Commit

Permalink
fix: add the ability to specify the NVD data directory
Browse files Browse the repository at this point in the history
  • Loading branch information
remie committed Dec 15, 2024
1 parent c273e8e commit c26d932
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/apt/helpers/generateSCAReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const generateSCAReport = async (options: TAPTSCAOptions) => {
mkdirSync(options.outputDir, { recursive: true });

// Create the data directory
const dataDir = join(homedir(), '.dcdx', 'owasp');
const dataDir = options.dataDir || join(homedir(), '.dcdx', 'owasp');
mkdirSync(dataDir, { recursive: true });

try {
Expand Down
2 changes: 2 additions & 0 deletions src/commands/apt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ const SCACommand = () => ({
await generateSCAReport({
nvdApiKey: options.nvdApiKey,
appKey: options.appKey,
dataDir: options.dataDir,
outputDir: options.outputDir || join(cwd(), 'sca_report')
});
},
Expand Down Expand Up @@ -509,6 +510,7 @@ To avoid rate limiting issues, providing an NVD API Key is required (see https:/
`)
.addOption(new Option('--nvdApiKey <key>', 'The NVD API key (defaults to NVD_API_KEY environment variable)').default(process.env.NVD_API_KEY))
.addOption(new Option('--appKey <appKey>', 'The key of the app to scan'))
.addOption(new Option('-D, --dataDir <path>', 'The path to the directory that contains the NVD database'))
.addOption(new Option('-O, --outputDir <path>', 'Specify the output directory where to store the generated report (defaults to `./sca_report`)'))
.action(options => ActionHandler(program, SCACommand(), options));

Expand Down
5 changes: 5 additions & 0 deletions src/types/DCAPT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,20 @@ export const APTDependencyTreeOptions = z.object({
export const APTSCAArgs = z.object({
nvdApiKey: z.string(),
appKey: z.string(),
dataDir: z.string(),
outputDir: z.string()
}).partial({
dataDir: true,
outputDir: true
});

export const APTSCAOptions = z.object({
nvdApiKey: z.string(),
appKey: z.string(),
dataDir: z.string(),
outputDir: z.string()
}).partial({
dataDir: true
});

export const APTArgs = z.intersection(
Expand Down

0 comments on commit c26d932

Please sign in to comment.