56 Commits

Author SHA1 Message Date
Sam Ford
69dcbacb71
shared_audits: prevent duplicate eol_data fetches
The `eol_data` method uses `@eol_data["#{product}/#{cycle}"] ||=`,
which can unncessarily allow a duplicate API call if the same
product/cycle combination was previously tried but returned a 404
(Not Found) response. In this scenario, the value would be `nil` but
the existing logic doesn't check whether this is a missing key or a
`nil` value. If the key is present, we shouldn't make the same
request again.

This updates the method to return the existing value if the key
exists, which effectively prevents duplicate fetches. This new logic
only modifies `@eol_data` if `curl` is successful, so it does allow
the request to be made again if it failed before.

That said, this shouldn't normally be an issue and this is mostly
about refactoring the method to allow for nicer code organization.
This approach reduces the `begin` block to only the `JSON.parse` call,
which allows us to use `return unless result.status.success?` (this
previously led to a RuboCop offense because it was called within a
`begin` block).
2025-05-03 21:15:11 -04:00
Sam Ford
85684f43bd
Update eol_data for API changes
The endoflife.date API has been updated, so this modifies the URL in
`SharedAudits.eol_data` to use the up to date URL and modifies the
related logic in `FormulaAuditor.audit_eol` to work with the new
response format. Specifically, there is now an `isEol` boolean value
and the EOL date is found in `eolFrom`.

One wrinkle of the new setup is that 404 responses now return HTML
content even if the request includes an `Accept: application/json`
header. This handles these types of responses by catching
`JSON::ParserError` but ideally we would parse the response headers
and use `Utils::Curl.http_status_ok?` to check for a good response
status before trying to parse the response body as JSON.
2025-05-03 12:26:54 -04:00
Sam Ford
cf22382921
Curl: use typed: strict
This upgrades `utils/curl.rb` to `typed: strict`, which requires
a number of changes to pass `brew typecheck`. The most
straightforward are adding type signatures to methods, adding type
annotations (e.g., `T.let`) to variables that need them, and ensuring
that methods always use the expected return type.

I had to refactor areas where we call a `Utils::Curl` method and use
array destructuring on a `SystemCommand::Result` return value
(e.g., `output, errors, status = curl_output(...)`), as Sorbet
doesn't understand implicit array conversion. As suggested by Markus,
I've switched these areas to use `#stdout`, `#stderr`, and `#status`.
This requires the use of an intermediate variable (`result`) in some
cases but this was a fairly straightforward substitution.

I also had to refactor how `Cask::URL::BlockDSL::PageWithURL` works.
It currently uses `page.extend PageWithURL` to add a `url` attribute
but this reworks it to subclass `SimpleDelegator` and use an
`initialize` method instead. This achieves the same goal but in a way
that Sorbet can understand.
2025-01-14 08:14:39 -05:00
Daeho Ro
05b97cdc48
fix prerelease check to allow standard release 2024-12-27 19:22:04 +09:00
Daeho Ro
d50e872fd8
update prerelease check to allow standard release 2024-12-25 20:52:38 +09:00
Daeho Ro
ce25ac7be6
update prerelease check to allow standard release 2024-12-25 16:57:07 +09:00
Bevan Kay
53e8739d24
utils/shared_audits: audit deprecate/disable reasons 2024-09-30 23:11:44 +10:00
Michael Cho
d1dc3b2206
utils/shared_audits: GitHub urls can have '.' in repo and '/' in tag 2024-08-27 11:39:50 -04:00
Michael Cho
cccab0d9a9
utils/shared_audits: allow subgroups in gitlab url 2024-08-26 23:07:31 -04:00
Bo Anderson
092dcdbeac
shared_audits: remove module_function 2024-08-23 03:34:48 +01:00
Rui Chen
1270eb37b1
formula_auditor: fix eol check
Co-authored-by: Ruoyu Zhong <zhongruoyu@outlook.com>
2024-08-13 16:36:38 +08:00
Issy Long
0355f07e0d
utils/shared_audits: Bump to Sorbet typed: strict 2024-08-10 16:43:37 +01:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Eric Knibbe
7698cf2098
audit: messaging improvements 2024-02-04 15:10:14 +01:00
Sean Molenaar
119e3d55ec chore: add audit to check if an EOL is known 2024-01-17 11:12:32 +01:00
Bo Anderson
5692c8ecbf
Fix style violations under newer RuboCop 2023-12-14 05:47:12 +00:00
Rui Chen
a496f6708e
audit(github): prefer /archive/refs/tags urls over /archive
Signed-off-by: Rui Chen <rui@chenrui.dev>
2023-10-23 11:00:27 -04:00
Mike McQuaid
0454669656
utils/shared_audits: handle 404 metadata errors from GitLab API.
Fixes #15995.
2023-09-13 09:31:34 +01:00
Mike McQuaid
b7114651ac
utils/curl: include or use explicitly.
Include or use `Utils::Curl` explicitly everywhere it is used.
2023-09-04 22:17:57 -04:00
Alexander Bayandin
45378f35e2 get_repo_license: ignore ip allowlist error 2023-08-26 17:16:43 +01:00
Alexander Bayandin
89d52f19a9
shared_audits: allow GitHub's IP not permitted error
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2023-08-26 14:53:38 +01:00
Troy McCabe
d490123d74 Second check for github repos as private homepages 2022-09-20 23:06:47 -05:00
Rylan Polster
fa4bb7d74a
Refactor audit exception handling 2021-10-21 21:11:05 -04:00
Michael Cho
3d2d7c93e7
audit: gitlab prerelease check keep time/zone 2021-08-24 20:10:01 -07:00
nandahkrishna
f7c8810214
utils/github/api: remove 'api' from method names 2021-02-17 23:47:05 +05:30
nandahkrishna
56e0c3d9e8
Update GitHub API usage 2021-02-15 22:38:27 +05:30
Rylan Polster
27ffa4e6e0 audit: fix prerelease audit 2020-12-24 13:55:16 -05:00
Rylan Polster
da29827a87 audit: cleanup shared audit exception handling 2020-12-22 10:51:29 -05:00
Rylan Polster
ec4fe89a94 audit: migrate shared audits to taps 2020-12-21 14:45:02 -05:00
miccal
aad02c4524 shared_audits: add xit to GITHUB_PRERELEASE_ALLOWLIST 2020-12-20 07:15:46 +08:00
Mike McQuaid
9216d8abe6
rubocop-rails: make fixes. 2020-12-02 10:43:04 +00:00
Vítor Galvão
9f9eaa3e6e Remove amd-power-gadget from prerelease exceptions 2020-11-21 19:01:18 +00:00
miccal
42881ebc55 shared_audits: add haptickey to GITHUB_PRERELEASE_ALLOWLIST 2020-11-18 06:54:24 +08:00
Jonathan Chang
500908ee6f rubocop: fix Lint/NoReturnInBeginEndBlocks 2020-11-10 23:28:31 +11:00
miccal
249088038c shared_audits: add lidarr to GITHUB_PRERELEASE_ALLOWLIST 2020-11-02 06:57:50 +08:00
miccal
a782406e08 shared_audits: add syntax-highlight to GITHUB_PRERELEASE_ALLOWLIST 2020-10-27 17:06:12 +08:00
Issy Long
6212c1d6c8
Remove infrakit from GITHUB_PRERELEASE_ALLOWLIST as it's deprecated 2020-10-25 14:28:40 +00:00
miccal
a176c3f75b shared_audits: add nuclear to GITHUB_PRERELEASE_ALLOWLIST 2020-10-25 06:13:26 +08:00
Caleb Xu
534f0e61e3 shared_audits: fix conditional in Bitbucket notability check
This check currently returns an error for repositories that are
notable enough (and passes on repositories that are not notable
enough).
2020-10-19 13:29:18 -04:00
miccal
c26f1f436e shared_audits: add extraterm to GITHUB_PRERELEASE_ALLOWLIST 2020-10-19 06:30:00 +08:00
Markus Reiter
ff653571b1 Create Utils::Curl module and explicitly include it. 2020-10-10 15:23:03 +02:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
miccal
41fe6b5e7c shared_audits: add home-assistant to GITHUB_PRERELEASE_ALLOWLIST 2020-10-06 06:05:50 +08:00
miccal
6efcde2eef shared_audts: add freetube to GITHUB_PRERELEASE_ALLOWLIST 2020-10-04 16:54:30 +08:00
Markus Reiter
94a306def6 Allow toggl-track to be a pre-release. 2020-09-13 01:14:16 +02:00
Seeker
e0645f3950 cask/audit: detect tag from URL 2020-09-09 08:57:56 -07:00
miccal
c22c6c4a93 Remove cbmc from GITHUB_PRERELEASE_ALLOWLIST 2020-09-09 05:27:18 +08:00
miccal
f2ff0c21ba Add pock to GITHUB_PRERELEASE_ALLOWLIST 2020-09-08 12:06:26 +08:00
Dustin Rodrigues
33de853b99
Merge pull request #8625 from dtrodrigues/gitlab-release
shared_audits: ensure GitLab API response is valid
2020-09-05 14:54:18 -04:00
Dustin Rodrigues
6a0f2b663d shared_audits: ensure GitLab API has successful response 2020-09-05 14:32:23 -04:00