Skip to content

Commit

Permalink
Merge pull request #3497 from snyk/chore/add-cwd-to-error-message
Browse files Browse the repository at this point in the history
chore: Added CWD path to out of CWD error message
  • Loading branch information
ofekatr authored Jul 27, 2022
2 parents 204d5f5 + 66803e0 commit 53bb090
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/cli/commands/test/iac/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export async function scan(
assertIaCOptionsFlags(process.argv);

if (pathLib.relative(projectRoot, path).includes('..')) {
throw new CurrentWorkingDirectoryTraversalError(path);
throw new CurrentWorkingDirectoryTraversalError(path, projectRoot);
}

const resultsProcessor = new SingleGroupResultsProcessor(
Expand Down Expand Up @@ -168,13 +168,15 @@ function formatTestError(error) {

class CurrentWorkingDirectoryTraversalError extends CustomError {
public filename: string;
public projectRoot: string;

constructor(path: string) {
constructor(path: string, projectRoot: string) {
super('Path is outside the current working directory');
this.code = IaCErrorCodes.CurrentWorkingDirectoryTraversalError;
this.strCode = getErrorStringCode(this.code);
this.userMessage = `Path is outside the current working directory`;
this.filename = path;
this.projectRoot = projectRoot;
}
}

Expand Down

0 comments on commit 53bb090

Please sign in to comment.