mirror of
https://github.com/step-security/harden-runner.git
synced 2026-06-08 06:17:07 +00:00
19 lines
No EOL
671 B
TypeScript
19 lines
No EOL
671 B
TypeScript
import * as core from "@actions/core";
|
|
import * as crypto from "crypto"
|
|
import * as fs from "fs"
|
|
|
|
export function verifyChecksum(downloadPath: string){
|
|
|
|
|
|
const fileBuffer:Buffer = fs.readFileSync(downloadPath)
|
|
const checksum: string = crypto.createHash("sha256").update(fileBuffer).digest('hex'); // checksum of downloaded file
|
|
|
|
const expectedChecksum: string = "a5f466fc5c8a9b809afd421e0f32903da98908feab5a245c734d3775e2e10032" // default checksum
|
|
|
|
if(checksum !== expectedChecksum){
|
|
core.setFailed(`Checksum verification failed, expected ${expectedChecksum} instead got ${checksum}`)
|
|
}
|
|
|
|
core.debug("Checksum verification passed.")
|
|
|
|
} |