From 3c347d4b45f901a8af389d557f9e47502a0e341e Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Tue, 25 Jan 2022 22:05:06 -0500 Subject: [PATCH] feat(app/metrics): check token format [skip ci] --- source/app/action/index.mjs | 3 +++ source/app/metrics/metadata.mjs | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/app/action/index.mjs b/source/app/action/index.mjs index 73abe773..01a31e3b 100644 --- a/source/app/action/index.mjs +++ b/source/app/action/index.mjs @@ -145,6 +145,9 @@ async function retry(func, {retries = 1, delay = 0} = {}) { //Token for data gathering info("GitHub token", token, {token:true}) + //A GitHub token should start with "gh" along an additional letter for type + //See https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats + info("GitHub token format", /^gh[pousr]_/.test(token) ? "correct" : "(old or invalid)") if (!token) throw new Error("You must provide a valid GitHub personal token to gather your metrics (see https://github.com/lowlighter/metrics/blob/master/.github/readme/partials/setup/action/setup.md for more informations)") conf.settings.token = token diff --git a/source/app/metrics/metadata.mjs b/source/app/metrics/metadata.mjs index 486ff706..3f26da47 100644 --- a/source/app/metrics/metadata.mjs +++ b/source/app/metrics/metadata.mjs @@ -253,13 +253,11 @@ metadata.plugin = async function({__plugins, __templates, name, logger}) { if ((key in preset)&&(unspecified)) { console.debug(`metrics/inputs > ${key} has been set by preset value`) q[key] = preset[key] - continue } //From defaults else if (unspecified) { console.debug(`metrics/inputs > ${key} has been set by default value`) q[key] = metadata.inputs[key]?.default - continue } //From user else {