Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Regal linting in CI pipeline #516

Closed
wants to merge 1 commit into from
Closed

Add Regal linting in CI pipeline #516

wants to merge 1 commit into from

Conversation

alegrey91
Copy link
Contributor

@alegrey91 alegrey91 commented Oct 6, 2023

PR Type:

Enhancement


PR Description:

This PR integrates Regal linting into the CI pipeline using the setup-regal GitHub Action. It also includes fixes for style violations from recent Regal rules and updates the Regal configuration to ignore some of the new rules. Additionally, the PR includes minor code style fixes in various Rego files.


PR Main Files Walkthrough:

files:

.github/workflows/pr-tests.yaml: Added setup for Regal and a new job for Rego linting.
rules/.regal/config.yaml: Updated Regal configuration to ignore some rules and set a maximum rule length.
rules/alert-rw-hostpath/raw.rego: Minor style fixes and comments update.
rules/CVE-2021-25742/raw.rego: Minor style fixes and comments update.
rules/exposed-critical-pods/raw.rego: Added a Regal ignore directive for rule length.
rules/CVE-2022-0185/raw.rego: Minor style fixes and comments update.
rules/exposed-rce-pods/raw.rego: Added a Regal ignore directive for rule length.
rules/rule-privileged-container/raw.rego: Minor style fixes and comments update.
rules/etcd-unique-ca/raw.rego: Minor style fixes and comments update.
rules/label-usage-for-resources/raw.rego: Minor style fixes and comments update.


User Description:

PR related to #515 for tests that make use of secrets.

Simplified now by the new [setup-regal](https://github.com/StyraInc/setup-regal) GitHub Action.
The new-ish `--format github` flag will also annotate PRs with any violation encountered
in the code at the location of the violation, making it really easy to spot.

Also fixed some style violations from more recent Regal rules, and amended the Regal
configuration to ignore some of the new rules that would require more work to enable.

Let me know what you all think, and have a great weekend!

Signed-off-by: Anders Eknert <[email protected]>
@codiumai-pr-agent-free codiumai-pr-agent-free bot added the enhancement New feature or request label Oct 6, 2023
@codiumai-pr-agent-free
Copy link
Contributor

PR Analysis

  • 🎯 Main theme: Integration of Regal linting into the CI pipeline and minor code style fixes
  • 📝 PR summary: This PR integrates Regal linting into the CI pipeline using the setup-regal GitHub Action. It also includes fixes for style violations from recent Regal rules and updates the Regal configuration to ignore some of the new rules. Additionally, the PR includes minor code style fixes in various Rego files.
  • 📌 Type of PR: Enhancement
  • 🧪 Relevant tests added: No
  • ⏱️ Estimated effort to review [1-5]: 3, because the PR includes changes in multiple files and introduces a new linting tool into the CI pipeline. However, most changes are minor style fixes.
  • 🔒 Security concerns: No security concerns found

PR Feedback

  • 💡 General suggestions: The PR is well-structured and the changes are clearly explained. The integration of Regal linting into the CI pipeline is a good step towards improving code quality. However, it would be beneficial to ensure that all contributors are aware of the new linting rules and how to use the linting tool.

  • 🤖 Code feedback:

    • relevant file: .github/workflows/pr-tests.yaml
      suggestion: Consider adding a step in the CI pipeline to fail the build when linting errors are detected. This will ensure that new code adheres to the established coding standards and style guidelines. [important]
      relevant line: - name: Lint Rego

    • relevant file: rules/.regal/config.yaml
      suggestion: It's good to see that some rules are being ignored for now, but consider gradually enabling them as the codebase matures. This will help maintain high code quality and consistency. [medium]
      relevant line: no-defined-entrypoint:

    • relevant file: rules/CVE-2021-25742/raw.rego
      suggestion: Regular expressions can be expensive in terms of performance. If the version format is always the same, consider using a simpler string manipulation method to extract the version number. [medium]
      relevant line: tag_version_match := regex.find_all_string_submatch_n([0-9]+\.[0-9]+\.[0-9]+, image, -1)[0][0]

    • relevant file: rules/kubelet-rotate-kubelet-server-certificate/raw.rego
      suggestion: Consider using the built-in split function instead of regex for splitting strings based on a simple delimiter. This can improve performance. [medium]
      relevant line: args := regex.split( +, command)

How to use

To invoke the PR-Agent, add a comment using one of the following commands:
/review [-i]: Request a review of your Pull Request. For an incremental review, which only considers changes since the last review, include the '-i' option.
/describe: Modify the PR title and description based on the contents of the PR.
/improve [--extended]: Suggest improvements to the code in the PR. Extended mode employs several calls, and provides a more thorough feedback.
/ask <QUESTION>: Pose a question about the PR.
/update_changelog: Update the changelog based on the PR's contents.

To edit any configuration parameter from configuration.toml, add --config_path=new_value
For example: /review --pr_reviewer.extra_instructions="focus on the file: ..."
To list the possible configuration parameters, use the /config command.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2023

Summary:

  • License scan: failure
  • Credentials scan: success
  • Vulnerabilities scan: failure
  • Unit test: success
  • Go linting: success

@alegrey91 alegrey91 closed this Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants