Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31926,6 +31926,13 @@ function detectThirdPartyRunnerProvider() {
return "blacksmith";
return null;
}
function stripEndpointComments(input) {
return input
.split("\n")
.map((line) => line.trim())
.filter((line) => line.length > 0 && !line.startsWith("#"))
.join("\n");
}
function utils_getAnnotationLogs(platform) {
switch (platform) {
case "linux":
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions dist/post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31932,6 +31932,13 @@ function detectThirdPartyRunnerProvider() {
return "blacksmith";
return null;
}
function stripEndpointComments(input) {
return input
.split("\n")
.map((line) => line.trim())
.filter((line) => line.length > 0 && !line.startsWith("#"))
.join("\n");
}
function getAnnotationLogs(platform) {
switch (platform) {
case "linux":
Expand Down
2 changes: 1 addition & 1 deletion dist/post/index.js.map

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion dist/pre/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85051,6 +85051,13 @@ function detectThirdPartyRunnerProvider() {
return "blacksmith";
return null;
}
function stripEndpointComments(input) {
return input
.split("\n")
.map((line) => line.trim())
.filter((line) => line.length > 0 && !line.startsWith("#"))
.join("\n");
}
function utils_getAnnotationLogs(platform) {
switch (platform) {
case "linux":
Expand Down Expand Up @@ -85827,7 +85834,7 @@ var __rest = (undefined && undefined.__rest) || function (s, e) {
working_directory: process.env["GITHUB_WORKSPACE"],
api_url: api_url,
telemetry_url: STEPSECURITY_TELEMETRY_URL,
allowed_endpoints: lib_core.getInput("allowed-endpoints"),
allowed_endpoints: stripEndpointComments(lib_core.getInput("allowed-endpoints")),
egress_policy: lib_core.getInput("egress-policy"),
disable_telemetry: lib_core.getBooleanInput("disable-telemetry"),
disable_sudo: lib_core.getBooleanInput("disable-sudo"),
Expand Down
2 changes: 1 addition & 1 deletion dist/pre/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
installWindowsAgent,
} from "./install-agent";

import { chownForFolder, detectThirdPartyRunnerProvider, isAgentInstalled, isPlatformSupported, shouldDeployAgentOnSelfHosted } from "./utils";
import { chownForFolder, detectThirdPartyRunnerProvider, isAgentInstalled, isPlatformSupported, shouldDeployAgentOnSelfHosted, stripEndpointComments } from "./utils";
import { buildBravoConfig } from "./bravo-config";

interface MonitorResponse {
Expand Down Expand Up @@ -82,7 +82,7 @@ interface MonitorResponse {
working_directory: process.env["GITHUB_WORKSPACE"],
api_url: api_url,
telemetry_url: STEPSECURITY_TELEMETRY_URL,
allowed_endpoints: core.getInput("allowed-endpoints"),
allowed_endpoints: stripEndpointComments(core.getInput("allowed-endpoints")),
egress_policy: core.getInput("egress-policy"),
disable_telemetry: core.getBooleanInput("disable-telemetry"),
disable_sudo: core.getBooleanInput("disable-sudo"),
Expand Down
23 changes: 22 additions & 1 deletion src/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { shouldDeployAgentOnSelfHosted, isAgentInstalled, isPlatformSupported, getAnnotationLogs, detectThirdPartyRunnerProvider } from "./utils";
import { shouldDeployAgentOnSelfHosted, isAgentInstalled, isPlatformSupported, getAnnotationLogs, detectThirdPartyRunnerProvider, stripEndpointComments } from "./utils";
import * as fs from "fs";

jest.mock("fs", () => ({
Expand Down Expand Up @@ -91,6 +91,27 @@ describe("getAnnotationLogs", () => {
});
});

describe("stripEndpointComments", () => {
test("removes comment lines starting with #", () => {
const input = "api.github.com:443\n# needed for npm\nregistry.npmjs.org:443";
expect(stripEndpointComments(input)).toBe("api.github.com:443\nregistry.npmjs.org:443");
});

test("removes blank lines", () => {
const input = "api.github.com:443\n\nregistry.npmjs.org:443\n";
expect(stripEndpointComments(input)).toBe("api.github.com:443\nregistry.npmjs.org:443");
});

test("returns empty string for empty input", () => {
expect(stripEndpointComments("")).toBe("");
});

test("returns empty string when input contains only comments", () => {
const input = "# comment one\n# comment two";
expect(stripEndpointComments(input)).toBe("");
});
});

describe("detectThirdPartyRunnerProvider", () => {
const originalEnv = process.env;

Expand Down
8 changes: 8 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ export function detectThirdPartyRunnerProvider(): ThirdPartyRunnerProvider | nul
return null;
}

export function stripEndpointComments(input: string): string {
return input
.split("\n")
.map((line) => line.trim())
.filter((line) => line.length > 0 && !line.startsWith("#"))
.join("\n");
}

export function getAnnotationLogs(platform: NodeJS.Platform) {
switch (platform) {
case "linux":
Expand Down