Skip to content

Commit 63c24ba

Browse files
Merge pull request #376 from step-security/rc-7
Release 2.7.0
2 parents dece111 + 95691d3 commit 63c24ba

15 files changed

+210
-42
lines changed

.github/workflows/canary.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,9 @@ jobs:
4141
env:
4242
PAT: ${{ secrets.PAT }}
4343
canary: true
44+
45+
- name: Canary TLS test
46+
uses: docker://ghcr.io/step-security/integration-test/int:latest
47+
env:
48+
PAT: ${{ secrets.PAT }}
49+
canary-tls: true

.github/workflows/recurring-int-tests.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,18 @@ jobs:
2222
env:
2323
PAT: ${{ secrets.PAT }}
2424
canary: true
25+
26+
int-tls-tests:
27+
name: int tls tests
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Harden Runner
31+
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895
32+
with:
33+
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
34+
35+
- name: Canary test
36+
uses: docker://ghcr.io/step-security/integration-test/int:latest
37+
env:
38+
PAT: ${{ secrets.PAT }}
39+
canary-tls: true

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ branding:
3333
icon: "check-square"
3434
color: "green"
3535
runs:
36-
using: "node16"
36+
using: "node20"
3737
pre: "dist/pre/index.js"
3838
main: "dist/index.js"
3939
post: "dist/post/index.js"

dist/pre/index.js

Lines changed: 71 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/pre/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "step-security-harden-runner",
3-
"version": "2.6.1",
3+
"version": "2.7.0",
44
"description": "Security agent for GitHub-hosted runner: block egress traffic & detect code overwrite to prevent breaches",
55
"main": "index.js",
66
"scripts": {

src/checksum.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@ import * as core from "@actions/core";
22
import * as crypto from "crypto";
33
import * as fs from "fs";
44

5-
export function verifyChecksum(downloadPath: string) {
5+
export function verifyChecksum(downloadPath: string, is_tls: boolean) {
66
const fileBuffer: Buffer = fs.readFileSync(downloadPath);
77
const checksum: string = crypto
88
.createHash("sha256")
99
.update(fileBuffer)
1010
.digest("hex"); // checksum of downloaded file
1111

12-
const expectedChecksum: string =
12+
let expectedChecksum: string =
1313
"ceb925c78e5c79af4f344f08f59bbdcf3376d20d15930a315f9b24b6c4d0328a"; // checksum for v0.13.5
1414

15+
if (is_tls) {
16+
expectedChecksum =
17+
"204c82116e8c0eebf5409bb2b81aa5d96fe32f0c5abc1cb0364ee70937c32056"; // checksum for tls_agent
18+
}
19+
1520
if (checksum !== expectedChecksum) {
1621
core.setFailed(
1722
`Checksum verification failed, expected ${expectedChecksum} instead got ${checksum}`

src/configs.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const STEPSECURITY_ENV = "agent"; // agent or int
2+
3+
export const STEPSECURITY_API_URL = `https://${STEPSECURITY_ENV}.api.stepsecurity.io/v1`;
4+
5+
export const STEPSECURITY_WEB_URL = "https://app.stepsecurity.io";

src/interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface Configuration {
99
disable_telemetry: boolean;
1010
disable_sudo: boolean;
1111
disable_file_monitoring: boolean;
12+
is_github_hosted: boolean;
1213
private: string;
1314
}
1415

src/policy-utils.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import nock from "nock";
2-
import { API_ENDPOINT, fetchPolicy, mergeConfigs } from "./policy-utils";
2+
import { fetchPolicy, mergeConfigs } from "./policy-utils";
33
import { Configuration, PolicyResponse } from "./interfaces";
4+
import { STEPSECURITY_API_URL } from "./configs";
45

56
test("success: fetching policy", async () => {
67
let owner = "h0x0er";
@@ -14,7 +15,7 @@ test("success: fetching policy", async () => {
1415
disable_sudo: false,
1516
disable_file_monitoring: false,
1617
};
17-
const policyScope = nock(`${API_ENDPOINT}`)
18+
const policyScope = nock(`${STEPSECURITY_API_URL}`)
1819
.get(`/github/${owner}/actions/policies/${policyName}`)
1920
.reply(200, response);
2021

@@ -37,6 +38,7 @@ test("merge configs", async () => {
3738
disable_sudo: false,
3839
disable_file_monitoring: false,
3940
private: "true",
41+
is_github_hosted: true,
4042
};
4143
let policyResponse: PolicyResponse = {
4244
owner: "h0x0er",
@@ -60,6 +62,7 @@ test("merge configs", async () => {
6062
disable_sudo: false,
6163
disable_file_monitoring: false,
6264
private: "true",
65+
is_github_hosted: true,
6366
};
6467

6568
localConfig = mergeConfigs(localConfig, policyResponse);

src/policy-utils.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
import { HttpClient } from "@actions/http-client";
22
import { PolicyResponse, Configuration } from "./interfaces";
3-
4-
export const API_ENDPOINT = "https://agent.api.stepsecurity.io/v1";
3+
import { STEPSECURITY_API_URL } from "./configs";
54

65
export async function fetchPolicy(
76
owner: string,
87
policyName: string,
98
idToken: string
109
): Promise<PolicyResponse> {
11-
1210
if (idToken === "") {
1311
throw new Error("[PolicyFetch]: id-token in empty");
1412
}
1513

16-
let policyEndpoint = `${API_ENDPOINT}/github/${owner}/actions/policies/${policyName}`;
14+
let policyEndpoint = `${STEPSECURITY_API_URL}/github/${owner}/actions/policies/${policyName}`;
1715

1816
let httpClient = new HttpClient();
1917

@@ -25,24 +23,24 @@ export async function fetchPolicy(
2523
let err = undefined;
2624

2725
let retry = 0;
28-
while(retry < 3){
29-
try{
30-
console.log(`Attempt: ${retry+1}`)
26+
while (retry < 3) {
27+
try {
28+
console.log(`Attempt: ${retry + 1}`);
3129
response = await httpClient.getJson<PolicyResponse>(
3230
policyEndpoint,
3331
headers
3432
);
3533
break;
36-
}catch(e){
37-
err = e
34+
} catch (e) {
35+
err = e;
3836
}
39-
retry += 1
37+
retry += 1;
4038
await sleep(1000);
4139
}
4240

43-
if(response === undefined && err !== undefined){
44-
throw new Error(`[Policy Fetch] ${err}`)
45-
}else{
41+
if (response === undefined && err !== undefined) {
42+
throw new Error(`[Policy Fetch] ${err}`);
43+
} else {
4644
return response.result;
4745
}
4846
}

0 commit comments

Comments
 (0)