Skip to content

Commit

Permalink
Merge pull request #14 from veracode/FixPolicyScanRewrites
Browse files Browse the repository at this point in the history
Fix policy scan rewrites
  • Loading branch information
julz0815 authored Mar 28, 2024
2 parents 6c3d58e + cb2e1c3 commit 24daea9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
8 changes: 6 additions & 2 deletions importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@ async function importFlaws(options) {

// figure out which file type we're dealing with, pipeline or policy
let scanType = '';
if('pipeline_scan' in flawData)
if('pipeline_scan' in flawData){
scanType = 'pipeline';
else if('_embedded' in flawData)
console.log('This is a pipeline scan')
}
else if('_embedded' in flawData){
scanType = 'policy';
console.log('This is a policy scan')
}
else
throw new Error ('Unknown file type for input file');

Expand Down
26 changes: 17 additions & 9 deletions policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,28 +200,36 @@ async function processPolicyFlaws(options, flawData) {
}

filename = flaw.finding_details.file_path
let filepath

var filepath = filename

console.log('File Path: '+filename+' before rewrite')
if (options.source_base_path_1 || options.source_base_path_2 || options.source_base_path_3){
orgPath1 = options.source_base_path_1.split(":")
orgPath2 = options.source_base_path_2.split(":")
orgPath3 = options.source_base_path_3.split(":")
console.log('path1: '+orgPath1[0]+' path2: '+orgPath2[0]+' path3: '+orgPath3[0])

if( filename.startsWith(orgPath1[0]) ){
console.log('file path1: '+filename)

if( filename.includes(orgPath1[0])) {
//console.log('file path1: '+filename)
filepath = replacePath(options.source_base_path_1, filename)
//console.log('Filepath rewrtie 1: '+filepath);
}
else if ( filename.startsWith(orgPath2[0]) ){
console.log('file path2: '+filename)
else if (filename.includes(orgPath2[0])){
//console.log('file path2: '+filename)
filepath = replacePath(options.source_base_path_2, filename)
//console.log('Filepath rewrite 2: '+filepath);
}
else if ( filename.startsWith(orgPath3[0]) ){
console.log('file path3: '+filename)
else if (filename.includes(orgPath3[0])){
//console.log('file path3: '+filename)
filepath = replacePath(options.source_base_path_3, filename)
//console.log('Filepath rewrite 3: '+filepath);
}
console.log('Filepath:'+filepath);
//console.log('Filepath end: '+filepath);
}

if ( filepath == "" ){
filepath = filename
}

linestart = eval(flaw.finding_details.file_line_number-5)
Expand Down

0 comments on commit 24daea9

Please sign in to comment.