feat: add package registry and maintainability check (#1400)#1403
feat: add package registry and maintainability check (#1400)#1403RuchitAgrawal wants to merge 21 commits into
Conversation
Signed-off-by: ruchitagrawal <rragrawal16@gmail.com>
|
@RuchitAgrawal Thanks for the PR! Could you suggest a few packages that would fail this check? That would help us identify good candidates to include in integration tests. |
|
@RuchitAgrawal Looks like the integration tests are failing. You can search for "case failed" in the log to see which test is failing. |
Signed-off-by: ruchitagrawal <rragrawal16@gmail.com>
@behnazh-w ,Here are a few packages that would fail across the check evaluation:
|
Found the issue and pushed a fix. |
Thanks a lot. For For the rest, we can add new integration tests since each test can cover a different scenario or failure reason. |
Signed-off-by: ruchitagrawal <rragrawal16@gmail.com>
|
@behnazh-w Thanks for the feedback! I've added the integration tests as suggested. Here is what was done:
All three new tests follow the same pattern i.e. the policy requires the check to pass, but since it correctly fails for these packages, we set expect_fail: true. Regarding the CI failures visible on the PR, those build tests were already failing on main before this PR . These changes don't touch any of those test cases. |
Signed-off-by: ruchitagrawal <rragrawal16@gmail.com>
|
Hi @behnazh-w, Out of the 18 failing tests, 1 was The problem was I applied the registry-maintainability policy to all arrow versions using a wildcard, assuming arrow@1.3.0 would pass. Fixed it in the latest commit, by scoping the policy to only |
Signed-off-by: ruchitagrawal <rragrawal16@gmail.com>
|
@behnazh-w Thanks for reviewing the PR. I have addressed all the comments in the latest commit. Kindly take another look when you get a chance. |
Signed-off-by: ruchitagrawal <rragrawal16@gmail.com>
|
@behnazh-w I have fixed the failing tests and feel it is ready for your review. Also, really appreciate all your reviews and guidance! I am still relatively new to open source but working on these PRs under your guidance has been a very good learning experience for me. |
|
@behnazh-w I have tested the failing integration test locally and found the issue. Corrected it and verified the test now passes locally. Thank you for your patience and guidance as I worked through errors with the CI tests over these last few commits. Kindly review this commit. |
|
@RuchitAgrawal thanks for the fixes. Looks like CI checks are stuck. To trigger the workflows, can you please amend the last commit and force push to your fork? |
Signed-off-by: ruchitagrawal <rragrawal16@gmail.com>
f8c76c7 to
3855537
Compare
|
@behnazh-w Done, amended and force-pushed, CI should trigger now. |
|
@behnazh-w The CI build test is still failing again. I spent some time debugging and checking the logs, but I'm honestly a bit stuck on why this specific error is happening. Could you please point me or guide me on what I might be missing? |
|
@RuchitAgrawal Running the |
…tainability check
7d690d0 to
a38c85a
Compare
|
@behnazh-w You are right, thanks for spotting this case! Both cases should definitely pass. I just pushed a fix with the following updates: Versioned case: The check was incorrectly using the pinned version's date. I have added a method to query Maven Central for the newest release date. No-version case: It was returning I have also included new unit and integration tests to cover both scenarios. |
…ogic Signed-off-by: ruchitagrawal <rragrawal16@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/macaron/slsa_analyzer/package_registry/maven_central_registry.py:332
timezoneis not imported in this module, sotz=timezone.utcwill raiseNameErrorat runtime infind_latest_release_timestamp. Since the module already importsUTCfromdatetime, use that directly (or importtimezone).
return datetime.fromtimestamp(round(timestamp / 1000), tz=timezone.utc)
| try: | ||
| commit_dt = datetime.fromisoformat(pushed_at) | ||
| days_since_commit = (now - commit_dt).days |
| try: | ||
| commit_dt = datetime.fromisoformat(pushed_at) | ||
| days_since_commit = (now - commit_dt).days | ||
| last_commit_date = commit_dt.strftime("%Y-%m-%d") |
|
Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA). To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application. When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated. If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
src/macaron/slsa_analyzer/package_registry/maven_central_registry.py:332
find_latest_release_timestampreturnstz=timezone.utc, buttimezoneis not imported in this module, so this will raiseNameErrorat runtime.find_publish_timestampalready uses the importedUTCconstant; use that here for consistency (or importtimezone).
return datetime.fromtimestamp(round(timestamp / 1000), tz=timezone.utc)
src/macaron/slsa_analyzer/checks/registry_maintainability_check.py:633
pushed_atvalues from the GitHub API are RFC3339 strings with a trailingZ(e.g.2026-01-01T00:00:00Z).datetime.fromisoformat()does not reliably accept theZsuffix on Python <3.11, so this will raiseValueErrorand silently disable the commit-recency signal. NormalizeZto+00:00(as is already done in the Maven no-version path).
if pushed_at:
# GitHub timestamps use the ``Z`` suffix; normalise for datetime.fromisoformat() on Python < 3.11.
try:
commit_dt = datetime.fromisoformat(pushed_at)
days_since_commit = (now - commit_dt).days
Signed-off-by: ruchitagrawal <rragrawal16@gmail.com>
Signed-off-by: ruchitagrawal <rragrawal16@gmail.com>
fbe560c to
03925df
Compare
|
Thank you for signing the OCA. |
|
Hey @behnazh-w , quick question before I push a fix. The Would it make sense to add |
Thanks, this is addressed now on |
Signed-off-by: ruchitagrawal <rragrawal16@gmail.com>
|
@behnazh-w Hello, addressed the CI failures from the upstream sync. Should be good and working now, Kindly review it. |
Summary
Adds a new check
mcn_registry_maintainability_1that validates whether a package exists on its public registry and is actively maintained.Description of changes
The check uses three signals when available:
find_publish_timestamp()to confirm the package exists and check how many days have passed since the last release. Exceeding the threshold fails the check.yankedflag for PyPI packages and thedeprecated fieldfor npm packages from existing registry JSON responses. A yanked or deprecated package always fails, regardless of release age.get_repo_data()to check if the repo is archived and how recently code was pushed. An archived repo always fails.Results include remediation guidance and links to the registry page and source repository. The inactivity threshold is configurable via
defaults.iniunderregistry_maintainability(default: 365 days).Related issues
Closes #1400
Checklist
verifiedlabel should appear next to all of your commits on GitHub.