From 08947d3b5b75c4e70a2f6a2373cceab6946e9263 Mon Sep 17 00:00:00 2001 From: h0x0er Date: Thu, 6 Jun 2024 11:20:34 +0530 Subject: [PATCH] otk: added one-time-key logic Signed-off-by: h0x0er --- src/interfaces.ts | 1 + src/policy-utils.test.ts | 2 ++ src/setup.ts | 3 +++ 3 files changed, 6 insertions(+) diff --git a/src/interfaces.ts b/src/interfaces.ts index f0b2b2a..f9a8983 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -12,6 +12,7 @@ export interface Configuration { is_github_hosted: boolean; private: string; is_debug: boolean; + one_time_key: string; } export interface PolicyResponse { diff --git a/src/policy-utils.test.ts b/src/policy-utils.test.ts index 1ee3377..9c71b50 100644 --- a/src/policy-utils.test.ts +++ b/src/policy-utils.test.ts @@ -40,6 +40,7 @@ test("merge configs", async () => { private: "true", is_github_hosted: true, is_debug: false, + one_time_key: "", }; let policyResponse: PolicyResponse = { owner: "h0x0er", @@ -65,6 +66,7 @@ test("merge configs", async () => { private: "true", is_github_hosted: true, is_debug: false, + one_time_key: "", }; localConfig = mergeConfigs(localConfig, policyResponse); diff --git a/src/setup.ts b/src/setup.ts index f8d7a61..354bd3a 100644 --- a/src/setup.ts +++ b/src/setup.ts @@ -28,6 +28,7 @@ import { isGithubHosted, isTLSEnabled } from "./tls-inspect"; interface MonitorResponse { runner_ip_address?: string; + one_time_key?: string; monitoring_started?: boolean; } @@ -60,6 +61,7 @@ interface MonitorResponse { private: context?.payload?.repository?.private || false, is_github_hosted: isGithubHosted(), is_debug: core.isDebug(), + one_time_key: "", }; let policyName = core.getInput("policy"); @@ -200,6 +202,7 @@ interface MonitorResponse { if (statusCode === 200 && responseData) { console.log(`Runner IP Address: ${responseData.runner_ip_address}`); + confg.one_time_key = responseData.one_time_key; addSummary = responseData.monitoring_started ? "true" : "false"; } } catch (e) {