Act on CodeQL's suggestions for tightening security / improving performance (#338)

* Act on CodeQL's actions/missing-workflow-permissions

https://codeql.github.com/codeql-query-help/actions/actions-missing-workflow-permissions/

* Be more specific in the matched regex

And don't match a group if we don't need to match one

* Make it slightly faster since we know what after -otp-

I create a const because both expressions are looking for
the same thing
This commit is contained in:
Paulo F. Oliveira
2025-05-30 01:57:00 +01:00
committed by GitHub
parent 889e64e95a
commit 65066e38a0
8 changed files with 24 additions and 12 deletions
+4 -3
View File
@@ -26068,10 +26068,11 @@ function requestedVersionFor(tool, version, originListing, mirrors) {
}
async function getElixirVersion(exSpec0, otpVersion0) {
const otpVersion = otpVersion0.match(/^([^-]+-)?(.+)$/)[2]
const otpVersion = otpVersion0.match(/^(?:OTP-)?(.+)$/)[1]
let otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1]
const userSuppliedOtp = exSpec0.match(/-otp-(\d+)/)?.[1] ?? null
const otpSuffix = /-otp-(\d+)/
const userSuppliedOtp = exSpec0.match(otpSuffix)?.[1] ?? null
if (userSuppliedOtp && isVersion(userSuppliedOtp)) {
otpVersionMajor = userSuppliedOtp
@@ -26079,7 +26080,7 @@ async function getElixirVersion(exSpec0, otpVersion0) {
const [otpVersionsForElixirMap, elixirVersions, originListing, hexMirrors] =
await getElixirVersions()
const spec = exSpec0.replace(/-otp-.*$/, '')
const spec = exSpec0.replace(otpSuffix, '')
const versions = elixirVersions
const elixirVersionFromSpec = getVersionFromSpec(spec, versions)