Skip to content

Commit

Permalink
Use custom artifact name to read previous report
Browse files Browse the repository at this point in the history
Use custom artifact name when reading the previous report not always
using the old/hardcoded name otherwise it would miss the artifact and
lead to new issues always.
Also, upload the artifact with the custom name even if there's no issue
raised as following runs my start raising it.

Close zaproxy#20.
See also zaproxy#21, which is the same but before the refactoring to
TypeScript.

Signed-off-by: thc202 <[email protected]>
  • Loading branch information
thc202 committed Apr 2, 2023
1 parent 69f4292 commit bea636f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/action-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ const actionHelper = {
owner: string,
repo: string,
workSpace: string,
runnerID: string
runnerID: string,
artifactName = "zap_scan"
) => {
let previousReport;
try {
Expand All @@ -259,7 +260,7 @@ const actionHelper = {
let artifactID;
if (artifacts.length !== 0) {
artifacts.forEach((a) => {
if (a["name"] === "zap_scan") {
if (a["name"] === artifactName) {
artifactID = a["id"];
}
});
Expand All @@ -275,13 +276,13 @@ const actionHelper = {

await new Promise<void>((resolve) =>
request(download.url)
.pipe(fs.createWriteStream(`${workSpace}/zap_scan.zip`))
.pipe(fs.createWriteStream(`${workSpace}/${artifactName}.zip`))
.on("finish", () => {
resolve();
})
);

const zip = new AdmZip(`${workSpace}/zap_scan.zip`);
const zip = new AdmZip(`${workSpace}/${artifactName}.zip`);
const zipEntries = zip.getEntries();

zipEntries.forEach(function (zipEntry) {
Expand Down
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const actionCommon = {
workSpace,
mdReportName,
jsonReportName,
htmlReportName
htmlReportName,
artifactName
);
return;
}
Expand Down Expand Up @@ -118,7 +119,8 @@ const actionCommon = {
owner,
repo,
workSpace,
previousRunnerID
previousRunnerID,
artifactName
);
if (previousReport === undefined) {
create_new_issue = true;
Expand Down

0 comments on commit bea636f

Please sign in to comment.