Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a14aead7a
|
||
|
|
5233336fd6
|
||
|
|
8656e4a384
|
||
|
|
570f8965f3
|
||
|
|
a276ec1f48
|
No files matched your search
@@ -0,0 +1,22 @@
|
||||
schema: 1
|
||||
scoped_delegation: true
|
||||
components:
|
||||
source:
|
||||
toolchains:
|
||||
node: 22.20.0
|
||||
build:
|
||||
tool: source
|
||||
commands:
|
||||
- - tracked-files
|
||||
verification:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
- develop
|
||||
- hotfix/**
|
||||
- main
|
||||
- master
|
||||
- qualification/**
|
||||
- rc
|
||||
- release/**
|
||||
tags: []
|
||||
@@ -0,0 +1,146 @@
|
||||
# DRAFT ONLY - NOT INSTALLED, NOT EXECUTED. Public, review-only.
|
||||
# ONE-KEY NPM_TOKEN recovery variant of the reviewed qrun-secret-export workflow.
|
||||
# Target path (after a new explicit owner decision): .github/workflows/qrun-secret-export.yml
|
||||
# Delivery: normal Gitea PR onto develop, mirrored only by the existing dedicated shadow worker.
|
||||
# Fails closed until the three PLACEHOLDER values below are replaced:
|
||||
# NONCE, RECIPIENT_FPR, RECIPIENT_PUBLIC_PEM.
|
||||
name: qrun-secret-export (one-shot, one-key NPM recovery only)
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
expected_head:
|
||||
description: "Full 40-hex SHA of develop HEAD; must equal github.sha"
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions: {} # artifact upload uses the runtime token, not GITHUB_TOKEN
|
||||
|
||||
env:
|
||||
# Non-sensitive, reviewed constants (replaced at approval time).
|
||||
NONCE: "6281c98f7a28fef56930c368dc19b97d"
|
||||
RECIPIENT_FPR: "ed79db8053ad8b1c910994e71d07c4c914c76ebeda2eae9db6f38ecdae4fef6e"
|
||||
|
||||
concurrency:
|
||||
group: qrun-secret-export
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
export:
|
||||
if: >-
|
||||
github.repository == 'QRun-IO/qqq-orb' &&
|
||||
github.ref == format('refs/heads/{0}', github.event.repository.default_branch) &&
|
||||
github.ref_name == 'develop' &&
|
||||
github.sha == inputs.expected_head &&
|
||||
github.run_attempt == 1
|
||||
runs-on: ubuntu-24.04 # GitHub-hosted; never self-hosted
|
||||
timeout-minutes: 10
|
||||
permissions: {}
|
||||
steps:
|
||||
# No checkout. No repo code. No network install. Node built-in crypto only.
|
||||
- name: Encrypt NPM_TOKEN to recipient
|
||||
env:
|
||||
# Exactly this one, on this step only.
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
# Non-secret context.
|
||||
EXPECTED_HEAD: ${{ inputs.expected_head }}
|
||||
RUN_ATTEMPT: ${{ github.run_attempt }}
|
||||
RECIPIENT_PUBLIC_PEM: |
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEApnXE0AUAvxG+UO+lBbcl
|
||||
eH+3MSgyGKo4xb78Z2ObhtwrgQXkzHhsvzH90APyx/Yh4IAlQ1e1G9P59b4Is6Mh
|
||||
yaZ7zyu+KPP5vCeE3uO7CLd8M9EAp5i+1us9VyOoHhkM/klMXDITac/6Z6rMozAC
|
||||
0wPhauwF4T/nsJqX1BFycL0p4FdFTHoSqfHNjiaKpN5ov43ho8E6MHVCsc2CEt1X
|
||||
I99olcXFTybbCjHm8vjDrd/CepTHn26GQkwmxY2mKm43prcSC3uzHyL3nWg4uyKa
|
||||
QzTjx9ff7fgcoOXO9/exZv3r5GDdFzGwBHE49PklCEAvbiu6y0smO4UhjEz4r/DN
|
||||
6ratnC6UUqT3SQ3Zh+MkMIUAXi5AJfPELgUv5idSafPcOkjVd25VKP2LmqFvNecj
|
||||
0LWX5HSVhDYb3LZiHqR1KY/+fBamyArfhEhHghLL5nhUN+EV/ba5wQgpUeG+STg8
|
||||
NmBcvN1zhblS+KrhOJ7HZrthOfdck6GqgXQX0YSeFYSGdDG+pUI5XqJwJ6rOMLKD
|
||||
iTpxB1JWgGpQxx4WX3/rFL9NJk5vfSUeAHFUzvyC3b8YGTIjfe6R08IDJK8nMLU3
|
||||
gqSzFDkCldSq7nzr/psKmrw+6/+dYVEQ2ZD506+S3JGfcw3PzajYIWI65yAx7EIg
|
||||
qNefU2CCRfPthnjw4WJhXbECAwEAAQ==
|
||||
-----END PUBLIC KEY-----
|
||||
run: |
|
||||
node --input-type=commonjs - <<'NODE'
|
||||
const c = require('crypto');
|
||||
const fs = require('fs');
|
||||
const E = process.env;
|
||||
const NAMES = ['NPM_TOKEN'];
|
||||
const bad = (m) => { const e = new Error(m); e.safe = true; throw e; };
|
||||
let pt = null, aes = null;
|
||||
try {
|
||||
if (E.GITHUB_REPOSITORY !== 'QRun-IO/qqq-orb') bad('repository guard');
|
||||
if (E.RUN_ATTEMPT !== '1') bad('attempt guard');
|
||||
if (!/^[0-9a-f]{40}$/.test(E.EXPECTED_HEAD || '') || E.EXPECTED_HEAD !== E.GITHUB_SHA) bad('head guard');
|
||||
if (!/^[0-9a-f]{32}$/.test(E.NONCE || '')) bad('nonce unset');
|
||||
if (!/^[0-9a-f]{64}$/.test(E.RECIPIENT_FPR || '')) bad('recipient fingerprint unset');
|
||||
|
||||
let pub;
|
||||
try { pub = c.createPublicKey(E.RECIPIENT_PUBLIC_PEM); } catch { bad('recipient key unset'); }
|
||||
if (pub.asymmetricKeyType !== 'rsa' || pub.asymmetricKeyDetails.modulusLength !== 4096) bad('recipient key type');
|
||||
const spki = pub.export({ type: 'spki', format: 'der' });
|
||||
const spkiSha = c.createHash('sha256').update(spki).digest('hex');
|
||||
if (spkiSha !== E.RECIPIENT_FPR) bad('recipient fingerprint mismatch');
|
||||
|
||||
const body = {};
|
||||
for (const n of NAMES) {
|
||||
if (!Object.prototype.hasOwnProperty.call(E, n) || typeof E[n] !== 'string') bad('missing secret field');
|
||||
body[n] = E[n];
|
||||
}
|
||||
const prov = {
|
||||
repository: E.GITHUB_REPOSITORY,
|
||||
source_sha: E.GITHUB_SHA,
|
||||
run_id: E.GITHUB_RUN_ID,
|
||||
run_attempt: E.RUN_ATTEMPT,
|
||||
operation_nonce: E.NONCE,
|
||||
};
|
||||
pt = Buffer.from(JSON.stringify({ ...prov, secrets: body }), 'utf8');
|
||||
for (const n of NAMES) delete body[n];
|
||||
|
||||
aes = c.randomBytes(32);
|
||||
const iv = c.randomBytes(12);
|
||||
const aad = Buffer.from(`qrun-secret-export/v1|${spkiSha}|${E.NONCE}`, 'utf8');
|
||||
const cipher = c.createCipheriv('aes-256-gcm', aes, iv);
|
||||
cipher.setAAD(aad);
|
||||
const ct = Buffer.concat([cipher.update(pt), cipher.final()]);
|
||||
const tag = cipher.getAuthTag();
|
||||
// oaepHash sets both the OAEP digest and the MGF1 digest (SHA-256 each).
|
||||
const wrapped = c.publicEncrypt(
|
||||
{ key: pub, padding: c.constants.RSA_PKCS1_OAEP_PADDING, oaepHash: 'sha256' }, aes);
|
||||
|
||||
const envelope = {
|
||||
version: 1,
|
||||
alg: 'RSA-OAEP-SHA256-MGF1SHA256+AES-256-GCM',
|
||||
recipient_fingerprint: spkiSha,
|
||||
provenance: prov,
|
||||
wrapped_key: wrapped.toString('base64'),
|
||||
iv: iv.toString('base64'),
|
||||
tag: tag.toString('base64'),
|
||||
ciphertext: ct.toString('base64'),
|
||||
};
|
||||
// Only file written: ciphertext, owner-only, create-exclusive.
|
||||
fs.writeFileSync(`${E.RUNNER_TEMP}/${E.NONCE}.envelope.json`,
|
||||
JSON.stringify(envelope), { mode: 0o600, flag: 'wx' });
|
||||
console.log('envelope: written');
|
||||
} catch (e) {
|
||||
console.error('envelope: failed' + (e && e.safe ? ` (${e.message})` : ''));
|
||||
process.exitCode = 1;
|
||||
} finally {
|
||||
if (pt) pt.fill(0);
|
||||
if (aes) aes.fill(0);
|
||||
for (const n of NAMES) delete process.env[n];
|
||||
}
|
||||
NODE
|
||||
|
||||
- name: Upload ciphertext artifact
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
|
||||
with:
|
||||
name: qrun-envelope-${{ env.NONCE }}
|
||||
path: ${{ runner.temp }}/${{ env.NONCE }}.envelope.json # single explicit file
|
||||
retention-days: 1
|
||||
compression-level: 0
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Remove local ciphertext
|
||||
if: always()
|
||||
run: rm -f -- "${RUNNER_TEMP}/${NONCE}.envelope.json"
|
||||
Reference in new issue
Block a user