From 0ca8fc3fd488ddaab3b692954a4c476678b9149b Mon Sep 17 00:00:00 2001 From: Phil McGee <45431592+phil-mcgee@users.noreply.github.com> Date: Thu, 5 May 2022 11:48:44 -0400 Subject: [PATCH 1/8] Add --verbose to gpg import command --- src/gpg.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gpg.ts b/src/gpg.ts index 82fd22ffe..a855a7c9f 100644 --- a/src/gpg.ts +++ b/src/gpg.ts @@ -28,7 +28,7 @@ export async function importKey(privateKey: string) { await exec.exec( 'gpg', - ['--batch', '--import-options', 'import-show', '--import', PRIVATE_KEY_FILE], + ['--batch', '--verbose', '--import-options', 'import-show', '--import', PRIVATE_KEY_FILE], options ); From c8d8cd659f953bc5c2748cf0183ee6d19ab7effb Mon Sep 17 00:00:00 2001 From: philmcgee Date: Thu, 5 May 2022 12:27:22 -0400 Subject: [PATCH 2/8] added temp file location to output --- src/gpg.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gpg.ts b/src/gpg.ts index a855a7c9f..f12709d42 100644 --- a/src/gpg.ts +++ b/src/gpg.ts @@ -2,6 +2,7 @@ import * as fs from 'fs'; import * as path from 'path'; import * as io from '@actions/io'; import * as exec from '@actions/exec'; +import * as core from '@actions/core'; import * as util from './util'; import { ExecOptions } from '@actions/exec/lib/interfaces'; @@ -15,6 +16,8 @@ export async function importKey(privateKey: string) { flag: 'w' }); + core.info(`PRIVATE_KEY_FILE: ${PRIVATE_KEY_FILE}`); + let output = ''; const options: ExecOptions = { From 2e1461f5b003741611ac97a82e9ebd485a18e008 Mon Sep 17 00:00:00 2001 From: philmcgee Date: Thu, 5 May 2022 12:35:26 -0400 Subject: [PATCH 3/8] add message to auth.ts --- src/auth.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/auth.ts b/src/auth.ts index a52306b0d..aceef1c4f 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -41,6 +41,7 @@ export async function configureAuthentication() { if (gpgPrivateKey) { core.info('Importing private gpg key'); + core.info('gpg.PRIVATE_KEY_FILE: ${gpg.PRIVATE_KEY_FILE}'); const keyFingerprint = (await gpg.importKey(gpgPrivateKey)) || ''; core.saveState(constants.STATE_GPG_PRIVATE_KEY_FINGERPRINT, keyFingerprint); } From 6bb60003430393f4bb347134bdc70650d93b5310 Mon Sep 17 00:00:00 2001 From: philmcgee Date: Thu, 5 May 2022 13:35:52 -0400 Subject: [PATCH 4/8] tweaked to trigger workflows --- src/auth.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/auth.ts b/src/auth.ts index aceef1c4f..2440465d6 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -41,6 +41,7 @@ export async function configureAuthentication() { if (gpgPrivateKey) { core.info('Importing private gpg key'); + // phil added this core.info('gpg.PRIVATE_KEY_FILE: ${gpg.PRIVATE_KEY_FILE}'); const keyFingerprint = (await gpg.importKey(gpgPrivateKey)) || ''; core.saveState(constants.STATE_GPG_PRIVATE_KEY_FINGERPRINT, keyFingerprint); From 25089bf5620464549f315cd34fda86dd5eed68e2 Mon Sep 17 00:00:00 2001 From: philmcgee Date: Thu, 5 May 2022 13:53:30 -0400 Subject: [PATCH 5/8] rebuilt before push --- dist/cleanup/index.js | 4 +++- dist/setup/index.js | 6 +++++- src/auth.ts | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index cfa2fb813..5153f301a 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -65731,6 +65731,7 @@ const fs = __importStar(__nccwpck_require__(7147)); const path = __importStar(__nccwpck_require__(1017)); const io = __importStar(__nccwpck_require__(7436)); const exec = __importStar(__nccwpck_require__(1514)); +const core = __importStar(__nccwpck_require__(2186)); const util = __importStar(__nccwpck_require__(2629)); exports.PRIVATE_KEY_FILE = path.join(util.getTempDir(), 'private-key.asc'); const PRIVATE_KEY_FINGERPRINT_REGEX = /\w{40}/; @@ -65740,6 +65741,7 @@ function importKey(privateKey) { encoding: 'utf-8', flag: 'w' }); + core.info(`PRIVATE_KEY_FILE: ${exports.PRIVATE_KEY_FILE}`); let output = ''; const options = { silent: true, @@ -65749,7 +65751,7 @@ function importKey(privateKey) { } } }; - yield exec.exec('gpg', ['--batch', '--import-options', 'import-show', '--import', exports.PRIVATE_KEY_FILE], options); + yield exec.exec('gpg', ['--batch', '--verbose', '--import-options', 'import-show', '--import', exports.PRIVATE_KEY_FILE], options); yield io.rmRF(exports.PRIVATE_KEY_FILE); const match = output.match(PRIVATE_KEY_FINGERPRINT_REGEX); return match && match[0]; diff --git a/dist/setup/index.js b/dist/setup/index.js index f2a2170f5..8ce42fa0f 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -100514,6 +100514,8 @@ function configureAuthentication() { yield createAuthenticationSettings(id, username, password, settingsDirectory, overwriteSettings, gpgPassphrase); if (gpgPrivateKey) { core.info('Importing private gpg key'); + // phil added this + core.info('gpg.PRIVATE_KEY_FILE: ${gpg.PRIVATE_KEY_FILE}'); const keyFingerprint = (yield gpg.importKey(gpgPrivateKey)) || ''; core.saveState(constants.STATE_GPG_PRIVATE_KEY_FINGERPRINT, keyFingerprint); } @@ -102139,6 +102141,7 @@ const fs = __importStar(__nccwpck_require__(7147)); const path = __importStar(__nccwpck_require__(1017)); const io = __importStar(__nccwpck_require__(7436)); const exec = __importStar(__nccwpck_require__(1514)); +const core = __importStar(__nccwpck_require__(2186)); const util = __importStar(__nccwpck_require__(2629)); exports.PRIVATE_KEY_FILE = path.join(util.getTempDir(), 'private-key.asc'); const PRIVATE_KEY_FINGERPRINT_REGEX = /\w{40}/; @@ -102148,6 +102151,7 @@ function importKey(privateKey) { encoding: 'utf-8', flag: 'w' }); + core.info(`PRIVATE_KEY_FILE: ${exports.PRIVATE_KEY_FILE}`); let output = ''; const options = { silent: true, @@ -102157,7 +102161,7 @@ function importKey(privateKey) { } } }; - yield exec.exec('gpg', ['--batch', '--import-options', 'import-show', '--import', exports.PRIVATE_KEY_FILE], options); + yield exec.exec('gpg', ['--batch', '--verbose', '--import-options', 'import-show', '--import', exports.PRIVATE_KEY_FILE], options); yield io.rmRF(exports.PRIVATE_KEY_FILE); const match = output.match(PRIVATE_KEY_FINGERPRINT_REGEX); return match && match[0]; diff --git a/src/auth.ts b/src/auth.ts index 2440465d6..efca123c6 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -42,7 +42,7 @@ export async function configureAuthentication() { if (gpgPrivateKey) { core.info('Importing private gpg key'); // phil added this - core.info('gpg.PRIVATE_KEY_FILE: ${gpg.PRIVATE_KEY_FILE}'); + core.info('gpg.PRIVATE_KEY_FILE: ${gpg.PRIVATE_KEY_FILE}'); const keyFingerprint = (await gpg.importKey(gpgPrivateKey)) || ''; core.saveState(constants.STATE_GPG_PRIVATE_KEY_FINGERPRINT, keyFingerprint); } From 20cd4b8a40cf6ab86eb2f691f63c08665e83fcb6 Mon Sep 17 00:00:00 2001 From: philmcgee Date: Thu, 5 May 2022 18:04:02 -0400 Subject: [PATCH 6/8] count key lines --- dist/cleanup/index.js | 2 ++ dist/setup/index.js | 4 ++-- src/auth.ts | 2 -- src/gpg.ts | 2 ++ 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index 5153f301a..c37e98421 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -65742,6 +65742,8 @@ function importKey(privateKey) { flag: 'w' }); core.info(`PRIVATE_KEY_FILE: ${exports.PRIVATE_KEY_FILE}`); + const lines = privateKey.split(/\r\n|\r|\n/).length; + core.info(`Private key contains ${lines} lines`); let output = ''; const options = { silent: true, diff --git a/dist/setup/index.js b/dist/setup/index.js index 8ce42fa0f..46985b457 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -100514,8 +100514,6 @@ function configureAuthentication() { yield createAuthenticationSettings(id, username, password, settingsDirectory, overwriteSettings, gpgPassphrase); if (gpgPrivateKey) { core.info('Importing private gpg key'); - // phil added this - core.info('gpg.PRIVATE_KEY_FILE: ${gpg.PRIVATE_KEY_FILE}'); const keyFingerprint = (yield gpg.importKey(gpgPrivateKey)) || ''; core.saveState(constants.STATE_GPG_PRIVATE_KEY_FINGERPRINT, keyFingerprint); } @@ -102152,6 +102150,8 @@ function importKey(privateKey) { flag: 'w' }); core.info(`PRIVATE_KEY_FILE: ${exports.PRIVATE_KEY_FILE}`); + const lines = privateKey.split(/\r\n|\r|\n/).length; + core.info(`Private key contains ${lines} lines`); let output = ''; const options = { silent: true, diff --git a/src/auth.ts b/src/auth.ts index efca123c6..a52306b0d 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -41,8 +41,6 @@ export async function configureAuthentication() { if (gpgPrivateKey) { core.info('Importing private gpg key'); - // phil added this - core.info('gpg.PRIVATE_KEY_FILE: ${gpg.PRIVATE_KEY_FILE}'); const keyFingerprint = (await gpg.importKey(gpgPrivateKey)) || ''; core.saveState(constants.STATE_GPG_PRIVATE_KEY_FINGERPRINT, keyFingerprint); } diff --git a/src/gpg.ts b/src/gpg.ts index f12709d42..9f633bfbb 100644 --- a/src/gpg.ts +++ b/src/gpg.ts @@ -17,6 +17,8 @@ export async function importKey(privateKey: string) { }); core.info(`PRIVATE_KEY_FILE: ${PRIVATE_KEY_FILE}`); + const lines = privateKey.split(/\r\n|\r|\n/).length; + core.info(`Private key contains ${lines} lines`); let output = ''; From 4651e75515bdd4df218b1b588df16a78b5dd4517 Mon Sep 17 00:00:00 2001 From: philmcgee Date: Thu, 5 May 2022 18:57:59 -0400 Subject: [PATCH 7/8] no show --- dist/cleanup/index.js | 3 +-- dist/setup/index.js | 3 +-- src/gpg.ts | 7 +------ 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index c37e98421..05d1662b2 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -65746,14 +65746,13 @@ function importKey(privateKey) { core.info(`Private key contains ${lines} lines`); let output = ''; const options = { - silent: true, listeners: { stdout: (data) => { output += data.toString(); } } }; - yield exec.exec('gpg', ['--batch', '--verbose', '--import-options', 'import-show', '--import', exports.PRIVATE_KEY_FILE], options); + yield exec.exec('gpg', ['--batch', '--verbose', '--import', exports.PRIVATE_KEY_FILE], options); yield io.rmRF(exports.PRIVATE_KEY_FILE); const match = output.match(PRIVATE_KEY_FINGERPRINT_REGEX); return match && match[0]; diff --git a/dist/setup/index.js b/dist/setup/index.js index 46985b457..beaa232ba 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -102154,14 +102154,13 @@ function importKey(privateKey) { core.info(`Private key contains ${lines} lines`); let output = ''; const options = { - silent: true, listeners: { stdout: (data) => { output += data.toString(); } } }; - yield exec.exec('gpg', ['--batch', '--verbose', '--import-options', 'import-show', '--import', exports.PRIVATE_KEY_FILE], options); + yield exec.exec('gpg', ['--batch', '--verbose', '--import', exports.PRIVATE_KEY_FILE], options); yield io.rmRF(exports.PRIVATE_KEY_FILE); const match = output.match(PRIVATE_KEY_FINGERPRINT_REGEX); return match && match[0]; diff --git a/src/gpg.ts b/src/gpg.ts index 9f633bfbb..bca091e42 100644 --- a/src/gpg.ts +++ b/src/gpg.ts @@ -23,7 +23,6 @@ export async function importKey(privateKey: string) { let output = ''; const options: ExecOptions = { - silent: true, listeners: { stdout: (data: Buffer) => { output += data.toString(); @@ -31,11 +30,7 @@ export async function importKey(privateKey: string) { } }; - await exec.exec( - 'gpg', - ['--batch', '--verbose', '--import-options', 'import-show', '--import', PRIVATE_KEY_FILE], - options - ); + await exec.exec('gpg', ['--batch', '--verbose', '--import', PRIVATE_KEY_FILE], options); await io.rmRF(PRIVATE_KEY_FILE); From 814c34fb0598fdb3a1e81bf6389c85aae9789719 Mon Sep 17 00:00:00 2001 From: philmcgee Date: Thu, 5 May 2022 19:55:29 -0400 Subject: [PATCH 8/8] allow 8 digit keys --- dist/cleanup/index.js | 2 +- dist/setup/index.js | 2 +- src/gpg.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index 05d1662b2..996b85052 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -65734,7 +65734,7 @@ const exec = __importStar(__nccwpck_require__(1514)); const core = __importStar(__nccwpck_require__(2186)); const util = __importStar(__nccwpck_require__(2629)); exports.PRIVATE_KEY_FILE = path.join(util.getTempDir(), 'private-key.asc'); -const PRIVATE_KEY_FINGERPRINT_REGEX = /\w{40}/; +const PRIVATE_KEY_FINGERPRINT_REGEX = /\w{8,40}/; function importKey(privateKey) { return __awaiter(this, void 0, void 0, function* () { fs.writeFileSync(exports.PRIVATE_KEY_FILE, privateKey, { diff --git a/dist/setup/index.js b/dist/setup/index.js index beaa232ba..0942bc0f1 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -102142,7 +102142,7 @@ const exec = __importStar(__nccwpck_require__(1514)); const core = __importStar(__nccwpck_require__(2186)); const util = __importStar(__nccwpck_require__(2629)); exports.PRIVATE_KEY_FILE = path.join(util.getTempDir(), 'private-key.asc'); -const PRIVATE_KEY_FINGERPRINT_REGEX = /\w{40}/; +const PRIVATE_KEY_FINGERPRINT_REGEX = /\w{8,40}/; function importKey(privateKey) { return __awaiter(this, void 0, void 0, function* () { fs.writeFileSync(exports.PRIVATE_KEY_FILE, privateKey, { diff --git a/src/gpg.ts b/src/gpg.ts index bca091e42..958d1a12d 100644 --- a/src/gpg.ts +++ b/src/gpg.ts @@ -8,7 +8,7 @@ import { ExecOptions } from '@actions/exec/lib/interfaces'; export const PRIVATE_KEY_FILE = path.join(util.getTempDir(), 'private-key.asc'); -const PRIVATE_KEY_FINGERPRINT_REGEX = /\w{40}/; +const PRIVATE_KEY_FINGERPRINT_REGEX = /\w{8,40}/; export async function importKey(privateKey: string) { fs.writeFileSync(PRIVATE_KEY_FILE, privateKey, {