Skip to content

Commit

Permalink
Merge pull request #12 from veracode/pathReplace
Browse files Browse the repository at this point in the history
path replace / commitHash
  • Loading branch information
julz0815 authored Mar 20, 2024
2 parents 32aa58d + 72d7095 commit 99e70df
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ inputs:
debug:
description: enable debug logging
required: false
commitHash:
description: commit hash
required: false

runs:
using: 'node20'
Expand Down
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ try {
const source_base_path_3 = core.getInput('source_base_path_3');
const fail_build = core.getInput('fail_build');
const debug = core.getInput('debug')
const commit_hash = process.env.GITHUB_SHA;
let commit_hash = core.getInput('commitHash');
if ( commit_hash == "" ){
commit_hash = process.env.GITHUB_SHA;
}
console.log('resultsFile: '+resultsFile+'\nwaitTime: '+waitTime+'\nsource_base_path_1: '+source_base_path_1+'\nsource_base_path_2: '+source_base_path_2+'\nsource_base_path_3: '+source_base_path_3+'\ncommit_hash: '+commit_hash+'\ndebug: '+debug)


let isPR
let owner
let repo

Expand Down
20 changes: 10 additions & 10 deletions pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ async function processPipelineFlaws(options, flawData) {
//rewrite path
function replacePath (rewrite, path){
replaceValues = rewrite.split(":")
//console.log('Value 1:'+replaceValues[0]+' Value 2: '+replaceValues[1]+' old path: '+path)
console.log('rewrite: '+rewrite+' Value 1:'+replaceValues[0]+' Value 2: '+replaceValues[1]+' old path: '+path)
newPath = path.replace(replaceValues[0],replaceValues[1])
//console.log('new Path:'+newPath)
console.log('new Path:'+newPath)
return newPath
}

Expand All @@ -236,21 +236,21 @@ async function processPipelineFlaws(options, flawData) {
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])
console.log('path1: '+orgPath1[0]+' path2: '+orgPath2[0]+' path3: '+orgPath3[0])

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

linestart = eval(flaw.files.source_file.line-5)
Expand Down
20 changes: 10 additions & 10 deletions policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,19 @@ async function processPolicyFlaws(options, flawData) {
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])
console.log('path1: '+orgPath1[0]+' path2: '+orgPath2[0]+' path3: '+orgPath3[0])

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

0 comments on commit 99e70df

Please sign in to comment.