Skip to content

Commit

Permalink
tools: deps update authenticate github api request
Browse files Browse the repository at this point in the history
PR-URL: nodejs#48200
Fixes: nodejs#48119
Refs: nodejs/security-wg#973
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Mestery <mestery@protonmail.com>
  • Loading branch information
fasenderos authored and Ceres6 committed Aug 14, 2023
1 parent 4701b5c commit 028be86
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 13 deletions.
7 changes: 6 additions & 1 deletion tools/dep_updaters/update-ada.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ DEPS_DIR="$BASE_DIR/deps"
. "$BASE_DIR/tools/dep_updaters/utils.sh"

NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
const res = await fetch('https://api.github.com/repos/ada-url/ada/releases/latest');
const res = await fetch('https://api.github.com/repos/ada-url/ada/releases/latest',
process.env.GITHUB_TOKEN && {
headers: {
"Authorization": `Bearer ${process.env.GITHUB_TOKEN}`
},
});
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
const { tag_name } = await res.json();
console.log(tag_name.replace('v', ''));
Expand Down
7 changes: 6 additions & 1 deletion tools/dep_updaters/update-base64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ DEPS_DIR="$BASE_DIR/deps"
. "$BASE_DIR/tools/dep_updaters/utils.sh"

NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
const res = await fetch('https://api.github.com/repos/aklomp/base64/releases/latest');
const res = await fetch('https://api.github.com/repos/aklomp/base64/releases/latest',
process.env.GITHUB_TOKEN && {
headers: {
"Authorization": `Bearer ${process.env.GITHUB_TOKEN}`
},
});
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
const { tag_name } = await res.json();
console.log(tag_name.replace('v', ''));
Expand Down
7 changes: 6 additions & 1 deletion tools/dep_updaters/update-brotli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ DEPS_DIR="$BASE_DIR/deps"
. "$BASE_DIR/tools/dep_updaters/utils.sh"

NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
const res = await fetch('https://api.github.com/repos/google/brotli/releases/latest');
const res = await fetch('https://api.github.com/repos/google/brotli/releases/latest',
process.env.GITHUB_TOKEN && {
headers: {
"Authorization": `Bearer ${process.env.GITHUB_TOKEN}`
},
});
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
const { tag_name } = await res.json();
console.log(tag_name.replace('v', ''));
Expand Down
7 changes: 6 additions & 1 deletion tools/dep_updaters/update-c-ares.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ DEPS_DIR="$BASE_DIR/deps"
. "$BASE_DIR/tools/dep_updaters/utils.sh"

NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
const res = await fetch('https://api.github.com/repos/c-ares/c-ares/releases/latest');
const res = await fetch('https://api.github.com/repos/c-ares/c-ares/releases/latest',
process.env.GITHUB_TOKEN && {
headers: {
"Authorization": `Bearer ${process.env.GITHUB_TOKEN}`
},
});
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
const { tag_name } = await res.json();
console.log(tag_name.replace('cares-', '').replaceAll('_', '.'));
Expand Down
7 changes: 6 additions & 1 deletion tools/dep_updaters/update-cjs-module-lexer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ DEPS_DIR="$BASE_DIR/deps"
NPM="$DEPS_DIR/npm/bin/npm-cli.js"

NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
const res = await fetch('https://api.github.com/repos/nodejs/cjs-module-lexer/tags');
const res = await fetch('https://api.github.com/repos/nodejs/cjs-module-lexer/tags',
process.env.GITHUB_TOKEN && {
headers: {
"Authorization": `Bearer ${process.env.GITHUB_TOKEN}`
},
});
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
const tags = await res.json();
const { name } = tags.at(0)
Expand Down
7 changes: 6 additions & 1 deletion tools/dep_updaters/update-icu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ TOOLS_DIR="$BASE_DIR/tools"
[ -x "$NODE" ] || NODE=$(command -v node)

NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
const res = await fetch('https://api.github.com/repos/unicode-org/icu/releases/latest');
const res = await fetch('https://api.github.com/repos/unicode-org/icu/releases/latest',
process.env.GITHUB_TOKEN && {
headers: {
"Authorization": `Bearer ${process.env.GITHUB_TOKEN}`
},
});
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
const { tag_name } = await res.json();
console.log(tag_name.replace('release-', '').replace('-','.'));
Expand Down
7 changes: 6 additions & 1 deletion tools/dep_updaters/update-libuv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ DEPS_DIR="$BASE_DIR/deps"
. "$BASE_DIR/tools/dep_updaters/utils.sh"

NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
const res = await fetch('https://api.github.com/repos/libuv/libuv/releases/latest');
const res = await fetch('https://api.github.com/repos/libuv/libuv/releases/latest',
process.env.GITHUB_TOKEN && {
headers: {
"Authorization": `Bearer ${process.env.GITHUB_TOKEN}`
},
});
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
const { tag_name } = await res.json();
console.log(tag_name.replace('v', ''));
Expand Down
7 changes: 6 additions & 1 deletion tools/dep_updaters/update-llhttp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ DEPS_DIR="${BASE_DIR}/deps"
. "$BASE_DIR/tools/dep_updaters/utils.sh"

NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
const res = await fetch('https://api.github.com/repos/nodejs/llhttp/releases/latest');
const res = await fetch('https://api.github.com/repos/nodejs/llhttp/releases/latest',
process.env.GITHUB_TOKEN && {
headers: {
"Authorization": `Bearer ${process.env.GITHUB_TOKEN}`
},
});
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
const { tag_name } = await res.json();
console.log(tag_name.replace('release/v', ''));
Expand Down
7 changes: 6 additions & 1 deletion tools/dep_updaters/update-nghttp2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ DEPS_DIR="$BASE_DIR/deps"
. "$BASE_DIR/tools/dep_updaters/utils.sh"

NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
const res = await fetch('https://api.github.com/repos/nghttp2/nghttp2/releases/latest');
const res = await fetch('https://api.github.com/repos/nghttp2/nghttp2/releases/latest',
process.env.GITHUB_TOKEN && {
headers: {
"Authorization": `Bearer ${process.env.GITHUB_TOKEN}`
},
});
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
const { tag_name } = await res.json();
console.log(tag_name.replace('v', ''));
Expand Down
7 changes: 6 additions & 1 deletion tools/dep_updaters/update-nghttp3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ DEPS_DIR="$BASE_DIR/deps"
. "$BASE_DIR/tools/dep_updaters/utils.sh"

NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
const res = await fetch('https://api.github.com/repos/ngtcp2/nghttp3/releases');
const res = await fetch('https://api.github.com/repos/ngtcp2/nghttp3/releases',
process.env.GITHUB_TOKEN && {
headers: {
"Authorization": `Bearer ${process.env.GITHUB_TOKEN}`
},
});
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
const releases = await res.json()
const { tag_name } = releases.at(0);
Expand Down
7 changes: 6 additions & 1 deletion tools/dep_updaters/update-ngtcp2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ DEPS_DIR="$BASE_DIR/deps"
. "$BASE_DIR/tools/dep_updaters/utils.sh"

NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
const res = await fetch('https://api.github.com/repos/ngtcp2/ngtcp2/releases');
const res = await fetch('https://api.github.com/repos/ngtcp2/ngtcp2/releases',
process.env.GITHUB_TOKEN && {
headers: {
"Authorization": `Bearer ${process.env.GITHUB_TOKEN}`
},
});
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
const releases = await res.json()
const { tag_name } = releases.at(0);
Expand Down
7 changes: 6 additions & 1 deletion tools/dep_updaters/update-simdutf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ DEPS_DIR="$BASE_DIR/deps"
. "$BASE_DIR/tools/dep_updaters/utils.sh"

NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
const res = await fetch('https://api.github.com/repos/simdutf/simdutf/releases/latest');
const res = await fetch('https://api.github.com/repos/simdutf/simdutf/releases/latest',
process.env.GITHUB_TOKEN && {
headers: {
"Authorization": `Bearer ${process.env.GITHUB_TOKEN}`
},
});
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
const { tag_name } = await res.json();
console.log(tag_name.replace('v', ''));
Expand Down
7 changes: 6 additions & 1 deletion tools/dep_updaters/update-uvwasi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ DEPS_DIR="$BASE_DIR/deps"
. "$BASE_DIR/tools/dep_updaters/utils.sh"

NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
const res = await fetch('https://api.github.com/repos/nodejs/uvwasi/releases/latest');
const res = await fetch('https://api.github.com/repos/nodejs/uvwasi/releases/latest',
process.env.GITHUB_TOKEN && {
headers: {
"Authorization": `Bearer ${process.env.GITHUB_TOKEN}`
},
});
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
const { tag_name } = await res.json();
console.log(tag_name.replace('v', ''));
Expand Down

0 comments on commit 028be86

Please sign in to comment.