Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log GitHub Actions runtime token access controls #707

Merged
merged 1 commit into from Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions dist/licenses.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -33,6 +33,7 @@
"@actions/github": "^5.1.1",
"csv-parse": "^5.3.3",
"handlebars": "^4.7.7",
"jwt-decode": "^3.1.2",
"semver": "^7.3.7",
"tmp": "^0.2.1"
},
Expand Down
9 changes: 9 additions & 0 deletions src/github.ts
@@ -0,0 +1,9 @@
import jwt_decode, {JwtPayload} from 'jwt-decode';

interface Jwt extends JwtPayload {
ac?: string;
}

export const parseRuntimeToken = (token: string): Jwt => {
return jwt_decode<Jwt>(token);
};
10 changes: 10 additions & 0 deletions src/main.ts
Expand Up @@ -2,6 +2,7 @@ import * as fs from 'fs';
import * as buildx from './buildx';
import * as context from './context';
import * as docker from './docker';
import * as github from './github';
import * as stateHelper from './state-helper';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
Expand All @@ -14,6 +15,15 @@ async function run(): Promise<void> {
// standalone if docker cli not available
const standalone = !(await docker.isAvailable());

await core.group(`GitHub Actions runtime token access controls`, async () => {
const actionsRuntimeToken = process.env['ACTIONS_RUNTIME_TOKEN'];
if (actionsRuntimeToken) {
core.info(JSON.stringify(JSON.parse(github.parseRuntimeToken(actionsRuntimeToken).ac as string), undefined, 2));
} else {
core.info(`ACTIONS_RUNTIME_TOKEN not set`);
}
});

core.startGroup(`Docker info`);
if (standalone) {
core.info(`Docker info skipped in standalone mode`);
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Expand Up @@ -2828,6 +2828,11 @@ json5@2.x, json5@^2.1.2:
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==

jwt-decode@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/jwt-decode/-/jwt-decode-3.1.2.tgz#3fb319f3675a2df0c2895c8f5e9fa4b67b04ed59"
integrity sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A==

kleur@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"
Expand Down