Skip to content

Only run default rules for running providers#866

Open
eemcmullan wants to merge 1 commit into
konveyor:mainfrom
eemcmullan:default-rules
Open

Only run default rules for running providers#866
eemcmullan wants to merge 1 commit into
konveyor:mainfrom
eemcmullan:default-rules

Conversation

@eemcmullan

@eemcmullan eemcmullan commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Koncur PR: 101

Fixes #865
Relies on konveyor/koncur#101

Summary by CodeRabbit

  • New Features

    • Default rulesets are now resolved automatically for supported providers.
    • Provider-specific ruleset directories are selected, deduplicated, and validated before use.
    • Analysis and rules testing now recognize bundled provider defaults consistently.
  • Bug Fixes

    • Improved container image setup for Podman installation.
    • Corrected default ruleset paths for local and container-based environments.
  • Tests

    • Added coverage for provider mappings, missing directories, empty roots, and duplicate paths.

Signed-off-by: Emily McMullan <emcmulla@redhat.com>
@eemcmullan
eemcmullan requested a review from jmle July 17, 2026 16:45
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Provider-specific bundled ruleset directories are now resolved and propagated through analysis and local/container environments. Provider metadata gains a default subdirectory, resolution is validated and tested, and the Docker build and analysis fixture are updated.

Changes

Provider-specific default rulesets

Layer / File(s) Summary
Ruleset mapping and path resolution
pkg/provider/environment.go, pkg/provider/rulesets.go, pkg/provider/rulesets_test.go
Provider default subdirectories are mapped, resolved under the rulesets root, filtered to existing directories, de-duplicated, sorted, and tested.
Provider metadata wiring and validation
cmd/analyze/run.go, cmd/rules/test/runner.go, cmd/analyze/analyze.go
Provider info construction includes default ruleset subdirectories, and analysis checks bundled-default availability through the provider mapping.
Environment ruleset paths
pkg/provider/env_local.go, pkg/provider/env_container.go, pkg/provider/env_local_test.go
Local and container environments now use provider-specific default ruleset paths, with local tests expecting the Java directory.

Container build setup

Layer / File(s) Summary
Podman installation layer
Dockerfile
The build removes the redhat-release package database entry before installing Podman from the configured AlmaLinux repository.

Analysis output fixture

Layer / File(s) Summary
Analysis fixture rulesets
test-data/analysis/analysis-output.yaml
Angular migration, Astro, and PatternFly ruleset blocks are removed from the fixture.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related issues

Possibly related PRs

  • konveyor/kantra#807 — Both changes modify bundled/default ruleset availability handling in analysis.
  • konveyor/kantra#819 — This PR introduces the provider-specific ruleset metadata and helpers that the referenced PR reverts.

Suggested reviewers: shawn-hurley, jmle

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: default rules are now run only for providers that actually have bundled defaults.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@eemcmullan eemcmullan added the cherry-pick/release-0.10 This PR should be cherry-picked to release-0.10 branch label Jul 17, 2026
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.29412% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.51%. Comparing base (f9686cc) to head (e1a70a5).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/analyze/run.go 0.00% 3 Missing ⚠️
cmd/analyze/analyze.go 0.00% 1 Missing ⚠️
pkg/provider/env_container.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #866      +/-   ##
==========================================
+ Coverage   56.31%   56.51%   +0.20%     
==========================================
  Files          61       62       +1     
  Lines        5015     5041      +26     
==========================================
+ Hits         2824     2849      +25     
- Misses       1872     1873       +1     
  Partials      319      319              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
Dockerfile (1)

100-101: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Clean the package manager cache to reduce image size.

To minimize the final image size, consider cleaning the package manager cache immediately after installing packages in the same RUN step.

♻️ Proposed fix
 RUN rpm -e --nodeps --justdb redhat-release && \
-    microdnf -y install podman
+    microdnf -y install podman && \
+    microdnf clean all
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Dockerfile` around lines 100 - 101, Update the Dockerfile RUN step that
installs podman with microdnf to clean the package manager cache immediately
afterward in the same layer, preserving the existing redhat-release removal and
installation commands.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Dockerfile`:
- Around line 93-98: Update the AlmaLinux repository configuration in the
Dockerfile so both repo entries use gpgcheck = 1 and include gpgkey =
https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux-9. Preserve the
existing repository definitions and apply these settings consistently to both
entries.

---

Nitpick comments:
In `@Dockerfile`:
- Around line 100-101: Update the Dockerfile RUN step that installs podman with
microdnf to clean the package manager cache immediately afterward in the same
layer, preserving the existing redhat-release removal and installation commands.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 13896b9b-77f5-4d48-9985-ced41dd250a3

📥 Commits

Reviewing files that changed from the base of the PR and between f9686cc and e1a70a5.

📒 Files selected for processing (11)
  • Dockerfile
  • cmd/analyze/analyze.go
  • cmd/analyze/run.go
  • cmd/rules/test/runner.go
  • pkg/provider/env_container.go
  • pkg/provider/env_local.go
  • pkg/provider/env_local_test.go
  • pkg/provider/environment.go
  • pkg/provider/rulesets.go
  • pkg/provider/rulesets_test.go
  • test-data/analysis/analysis-output.yaml
💤 Files with no reviewable changes (1)
  • test-data/analysis/analysis-output.yaml

Comment thread Dockerfile
Comment on lines +93 to 98
"\ngpgcheck = 0" \
"\n[almalinux9-baseos]" \
"\nname = almalinux9-baseos" \
"\nbaseurl = https://repo.almalinux.org/almalinux/9/BaseOS/\$basearch/os/" \
"\nenabled = 1" \
"\ngpgcheck = 0" > /etc/yum.repos.d/almalinux.repo

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the Dockerfile and inspect the relevant section with line numbers.
file=$(git ls-files | rg '(^|/)Dockerfile$' | head -n 1)
echo "FILE=$file"
wc -l "$file"
sed -n '80,115p' "$file" | cat -n

Repository: konveyor/kantra

Length of output: 2036


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read the surrounding install commands to understand the repo configuration and cleanup flow.
file=$(git ls-files | rg '(^|/)Dockerfile$' | head -n 1)
rg -n -C 3 'gpgcheck|gpgkey|microdnf clean all|podman|almalinux' "$file"

Repository: konveyor/kantra

Length of output: 853


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check whether the Dockerfile already performs package-manager cleanup elsewhere.
file=$(git ls-files | rg '(^|/)Dockerfile$' | head -n 1)
rg -n 'microdnf clean all|dnf clean all|yum clean all|clean all' "$file" || true

Repository: konveyor/kantra

Length of output: 153


🌐 Web query:

AlmaLinux 9 RPM-GPG-KEY-AlmaLinux-9 official repo documentation gpgcheck baseurl

💡 Result:

For AlmaLinux 9, the official GPG key used to sign packages and repositories is RPM-GPG-KEY-AlmaLinux-9 [1][2]. Repository Configuration When configuring repositories in AlmaLinux 9, it is standard practice to enable security checks to ensure the authenticity of packages [1][3]. The relevant settings within a repository file (typically located in /etc/yum.repos.d/) are: gpgcheck=1: This setting enables signature verification for individual packages [4][5]. It is recommended to always keep this set to 1 in production environments [4][3]. repo_gpgcheck=1: This optional but recommended setting in dnf.conf or individual repository files ensures that the repository metadata itself is verified [6]. gpgkey: This directive points to the location of the GPG public key [4]. For official AlmaLinux repositories, this is often set to a file path such as file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-9 [1][7]. Key Location and Import The official key file, RPM-GPG-KEY-AlmaLinux-9, is available from the official AlmaLinux repositories [8]. When manually importing the key to your system's keyring (which allows rpm and dnf to verify packages signed by that key), you can use the following command [9][10][5]: sudo rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux-9 If you encounter issues where the system cannot verify a package, ensure the key is correctly imported [5][11]. You can temporarily bypass verification for troubleshooting purposes using --nogpgcheck (e.g., sudo dnf install --nogpgcheck), but this is not recommended for production systems due to the security risks of installing unverified software [4][5].

Citations:


🌐 Web query:

site:almalinux.org RPM-GPG-KEY-AlmaLinux-9 repo.almalinux.org AlmaLinux 9 official key URL

💡 Result:

The official URL for the AlmaLinux 9 GPG key is https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux-9 [1][2][3]. On AlmaLinux 9 systems, this key is typically already installed and located at /etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-9 [4][3]. If you need to manually import or verify the key, the official AlmaLinux documentation provides the following fingerprint for verification: BF18AC2876178908D6E71267D36CB86CB86B3716 [3].

Citations:


Enable GPG checks for the AlmaLinux repos.
gpgcheck = 0 disables package signature verification for both repo entries; switch both to gpgcheck = 1 and set gpgkey = https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux-9.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Dockerfile` around lines 93 - 98, Update the AlmaLinux repository
configuration in the Dockerfile so both repo entries use gpgcheck = 1 and
include gpgkey = https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux-9.
Preserve the existing repository definitions and apply these settings
consistently to both entries.

@mguetta1 mguetta1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just one point is to make sure the corresponding change is in the hub if needed and that it doesn't break the koncur hub tests. Thank you!

@eemcmullan eemcmullan closed this Jul 20, 2026
@eemcmullan eemcmullan reopened this Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick/release-0.10 This PR should be cherry-picked to release-0.10 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Only run default rulesets for running provider(s)

2 participants