Sanitize artifact name before using
This commit is contained in:
parent
ea169430d2
commit
f360da772a
9 changed files with 30 additions and 6 deletions
|
|
@ -680,3 +680,13 @@ test("isAnalyzingDefaultBranch()", async (t) => {
|
|||
t.deepEqual(await actionsutil.isAnalyzingDefaultBranch(), false);
|
||||
});
|
||||
});
|
||||
|
||||
test("sanitizeArifactName", (t) => {
|
||||
t.deepEqual(actionsutil.sanitizeArifactName("hello-world_"), "hello-world_");
|
||||
t.deepEqual(actionsutil.sanitizeArifactName("hello`world`"), "helloworld");
|
||||
t.deepEqual(actionsutil.sanitizeArifactName("hello===123"), "hello123");
|
||||
t.deepEqual(
|
||||
actionsutil.sanitizeArifactName("*m)a&n^y%i££n+v!a:l[i]d"),
|
||||
"manyinvalid"
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -709,3 +709,7 @@ export async function isAnalyzingDefaultBranch(): Promise<boolean> {
|
|||
|
||||
return currentRef === defaultBranch;
|
||||
}
|
||||
|
||||
export function sanitizeArifactName(name: string): string {
|
||||
return name.replace(/[^a-zA-Z0-9_\\-]+/g, "");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ async function uploadDebugArtifacts(toUpload: string[], rootDir: string) {
|
|||
suffix += `-${entry[1]}`;
|
||||
}
|
||||
await artifact.create().uploadArtifact(
|
||||
`${DEBUG_ARTIFACT_NAME}${suffix}`,
|
||||
actionsUtil.sanitizeArifactName(`${DEBUG_ARTIFACT_NAME}${suffix}`),
|
||||
toUpload.map((file) => path.normalize(file)),
|
||||
path.normalize(rootDir)
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue