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

Code ql #860

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Code ql #860

wants to merge 11 commits into from

Conversation

hupling
Copy link
Contributor

@hupling hupling commented Mar 6, 2025

Reference

Issue: it-at-m/.github#123

Summary by CodeRabbit

  • New Features
    • Enhanced automated security and quality analysis that now targets only areas affected by recent changes.
    • Introduced tailored scanning for different programming languages (Java, JavaScript/TypeScript/Vue, and Python) to ensure a more efficient review process.
    • Improved configuration settings allow for more precise analysis and better management of security events.

@hupling hupling requested a review from a team as a code owner March 6, 2025 13:08
Copy link
Contributor

coderabbitai bot commented Mar 6, 2025

Warning

Rate limit exceeded

@hupling has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 17 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 15d10d9 and 6873c5f.

📒 Files selected for processing (1)
  • .github/workflows/codeql.yml (1 hunks)

Walkthrough

The changes update the CodeQL workflow by introducing multiple jobs for language-specific analysis. A preliminary job checks for file changes and determines which languages require analysis. New environment variables configure aspects of the analysis for Java, JavaScript/TypeScript/Vue, and Python. The workflow now runs separate jobs for each language, controlled by the outputs of the file-checking step, ensuring targeted and efficient security and quality analyses.

Changes

File Change Summary
.github/workflows/codeql.yml - Introduced multiple jobs: check-changes, codeql-java, codeql-javascript-typescript-vue, codeql-python
- Added environment variables for language analysis settings and configurations
- Expanded permissions and conditional job execution

Sequence Diagram(s)

sequenceDiagram
    participant Repo as Repository
    participant Wf as CodeQL Workflow
    participant Check as check-changes Job
    participant Java as codeql-java Job
    participant JS as codeql-javascript/typescript/vue Job
    participant Py as codeql-python Job

    Repo->>Wf: Push changes
    Wf->>Check: Trigger check-changes job
    Check-->>Wf: Return file change outputs
    alt Java files changed
        Wf->>Java: Execute Java analysis job
    end
    alt JS/TS/Vue files changed
        Wf->>JS: Execute JavaScript/TypeScript/Vue analysis job
    end
    alt Python files changed
        Wf->>Py: Execute Python analysis job
    end
Loading

Poem

Oh, what a joyful day in the code garden,
I hop along the workflow, file changes pardoned.
From Java to Python, each step is a rhyme,
Each job a little hop in perfect time.
With whiskers twitching for bugs, I cheerfully bound—
A rabbit’s delight in each quality sound!
🐇✨


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@hupling hupling marked this pull request as draft March 6, 2025 13:09
@hupling hupling linked an issue Mar 6, 2025 that may be closed by this pull request
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 15d10d9 and b98349d.

📒 Files selected for processing (1)
  • .github/workflows/codeql.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/codeql.yml

69-69: context "env" is not allowed here. available contexts are "github", "inputs", "needs", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details

(expression)


73-73: context "env" is not allowed here. available contexts are "github", "inputs", "needs", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details

(expression)


86-86: context "env" is not allowed here. available contexts are "github", "inputs", "needs", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details

(expression)


96-96: context "env" is not allowed here. available contexts are "github", "inputs", "needs", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details

(expression)

🪛 YAMLlint (1.35.1)
.github/workflows/codeql.yml

[error] 7-7: trailing spaces

(trailing-spaces)


[error] 18-18: trailing spaces

(trailing-spaces)


[warning] 20-20: truthy value should be one of [false, true]

(truthy)


[error] 22-22: wrong indentation: expected 6 but found 2

(indentation)


[error] 24-24: wrong indentation: expected 8 but found 4

(indentation)


[error] 27-27: wrong indentation: expected 6 but found 2

(indentation)


[error] 31-31: wrong indentation: expected 6 but found 2

(indentation)


[error] 35-35: wrong indentation: expected 6 but found 2

(indentation)


[error] 36-36: wrong indentation: expected 8 but found 4

(indentation)


[error] 39-39: wrong indentation: expected 10 but found 6

(indentation)


[error] 41-41: wrong indentation: expected 10 but found 6

(indentation)


[error] 45-45: wrong indentation: expected 10 but found 6

(indentation)


[warning] 46-46: too few spaces before comment

(comments)


[warning] 48-48: too few spaces before comment

(comments)


[error] 51-51: wrong indentation: expected 14 but found 10

(indentation)


[error] 65-65: wrong indentation: expected 8 but found 4

(indentation)


[error] 68-68: trailing spaces

(trailing-spaces)


[error] 71-71: wrong indentation: expected 10 but found 6

(indentation)


[error] 73-73: wrong indentation: expected 12 but found 8

(indentation)


[error] 75-75: wrong indentation: expected 10 but found 6

(indentation)


[error] 77-77: wrong indentation: expected 14 but found 10

(indentation)


[error] 83-83: wrong indentation: expected 8 but found 4

(indentation)


[error] 88-88: wrong indentation: expected 10 but found 6

(indentation)


[error] 90-90: wrong indentation: expected 14 but found 10

(indentation)


[error] 93-93: wrong indentation: expected 8 but found 4

(indentation)


[error] 98-98: wrong indentation: expected 10 but found 6

(indentation)


[error] 100-100: wrong indentation: expected 14 but found 10

(indentation)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (refarch-backend)
🔇 Additional comments (2)
.github/workflows/codeql.yml (2)

35-44: Job 'check-changes': Configuration Looks Good
The check-changes job is properly defined—it checks out the repository and filters files for different languages. No functional issues were noted here; ensure, however, that all indentation remains consistent throughout the file.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 35-35: wrong indentation: expected 6 but found 2

(indentation)


[error] 36-36: wrong indentation: expected 8 but found 4

(indentation)


[error] 39-39: wrong indentation: expected 10 but found 6

(indentation)


[error] 41-41: wrong indentation: expected 10 but found 6

(indentation)


52-63: Filters Block: Approved Configuration
The filters listing for Java, JavaScript/TypeScript/Vue, and Python files is well configured. The use of multiple glob patterns is appropriate and aligns with the intended file filtering logic.

Comment on lines 3 to 18
env:
# Whether to analyze Java code or not (only set to true if repo has Java source code)
analyze-java: true
# Build mode to use for analysis of Java code (e.g. none, autobuild, manual)
java-buildmode: "autobuild"
# Temurin JDK version to use for autobuild (only when java-buildmode is set to autobuild)
java-version: "21"
# JSON array formatted as string, contains the paths to the java projects to build
java-build-paths: "['./refarch-backend','./refarch-eai']"
# Whether to analyze JavaScript/TypeScript/Vue code or not (only set to true if repo has Javascript/Typescript/Vue source code)
analyze-javascript-typescript-vue: true
# Whether to analyze Python code or not (only set to true if repo has Python source code)
analyze-python: false
# Query set to use when analyzing the source code (e.g. default, security-extended, security-and-quality)
analysis-query: security-and-quality

Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

🛠️ Refactor suggestion

Environment Variables Block: Fix Formatting & Trailing Spaces
The environment variable definitions are correctly set up to configure analysis parameters; however, YAMLlint reports trailing spaces (notably on line 7 and line 18) and potential indentation inconsistencies. Please remove the extra spaces and ensure that the indentation meets YAMLlint expectations for better readability and maintainability.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 7-7: trailing spaces

(trailing-spaces)


[error] 18-18: trailing spaces

(trailing-spaces)

Comment on lines +26 to +29
permissions:
pull-requests: read
security-events: write

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Permissions Block: Align Indentation
The permissions block is essential for setting access rights. YAMLlint has flagged indentation errors (for example, "expected 6 but found 2" for the pull-requests key). Please adjust the indentation so that it complies with GitHub Actions’ schema and YAMLlint rules.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 27-27: wrong indentation: expected 6 but found 2

(indentation)

Comment on lines +30 to +33
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Concurrency Block: Correct Indentation
The concurrency settings are important to prevent overlapping jobs. YAMLlint indicates problematic indentation (e.g., "expected 6 but found 2" on line 31). Please fix the indentation to match the expected structure.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 31-31: wrong indentation: expected 6 but found 2

(indentation)

Comment on lines 45 to 51
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Check changed files and directories
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
filters: |
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Step Comments: Adjust Spacing
The steps in the check-changes job are clear, though YAMLlint warns about comments with too few spaces preceding them (e.g., on line 46 and 48). A minor adjustment to the inline comment spacing would improve readability.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 45-45: wrong indentation: expected 10 but found 6

(indentation)


[warning] 46-46: too few spaces before comment

(comments)


[warning] 48-48: too few spaces before comment

(comments)


[error] 51-51: wrong indentation: expected 14 but found 10

(indentation)

name: Analyze JavaScript/TypeScript/Vue source files
runs-on: ubuntu-latest
needs: check-changes
if: env.analyze-javascript-typescript-vue && (github.ref_name == 'main' || needs.check-changes.outputs.javascript-typescript-vue == 'true')
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Job 'codeql-javascript-typescript-vue': Correct Context Usage in "if" Condition
On line 86 the condition

if: env.analyze-javascript-typescript-vue && (github.ref_name == 'main' || needs.check-changes.outputs.javascript-typescript-vue == 'true')

uses env.analyze-javascript-typescript-vue, which is not permitted in the if expression. Define this value in a vars block (or another allowed context) and reference it accordingly.

🧰 Tools
🪛 actionlint (1.7.4)

86-86: context "env" is not allowed here. available contexts are "github", "inputs", "needs", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details

(expression)

name: Analyze Python source files
runs-on: ubuntu-latest
needs: check-changes
if: env.analyze-python && (github.ref_name == 'main' || needs.check-changes.outputs.python == 'true')
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Job 'codeql-python': Replace Disallowed env Reference in "if" Expression
Similarly, the if condition on line 96 uses

if: env.analyze-python && (github.ref_name == 'main' || needs.check-changes.outputs.python == 'true')

Since the env context isn’t available here, please migrate this reference to a variable defined in an allowed context (e.g., vars). For example:

-    if: env.analyze-python && (github.ref_name == 'main' || needs.check-changes.outputs.python == 'true')
+    if: vars.analyze_python && (github.ref_name == 'main' || needs.check-changes.outputs.python == 'true')

Ensure you update the variable declarations accordingly.

🧰 Tools
🪛 actionlint (1.7.4)

96-96: context "env" is not allowed here. available contexts are "github", "inputs", "needs", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details

(expression)

Comment on lines 69 to 73
if: env.analyze-java && (github.ref_name == 'main' || needs.check-changes.outputs.java == 'true')
strategy:
fail-fast: false
matrix:
build-path: ${{ fromJSON(env.java-build-paths) }}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Job 'codeql-java': Avoid Using env in "if" Condition and Matrix
In this job, the if condition on line 69 uses env.analyze-java and the matrix definition on line 73 retrieves values using env.java-build-paths. However, GitHub Actions does not allow direct use of the env context in these expressions (only github, inputs, needs, or vars are permitted).

Suggested Fix:
Consider defining these values as workflow or job-level variables (using the vars key) and referencing them accordingly. For example:

-    if: env.analyze-java && (github.ref_name == 'main' || needs.check-changes.outputs.java == 'true')
+    if: vars.analyze_java && (github.ref_name == 'main' || needs.check-changes.outputs.java == 'true')
-        build-path: ${{ fromJSON(env.java-build-paths) }}
+        build-path: ${{ fromJSON(vars.java_build_paths) }}

Make sure to update the variable definitions accordingly.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if: env.analyze-java && (github.ref_name == 'main' || needs.check-changes.outputs.java == 'true')
strategy:
fail-fast: false
matrix:
build-path: ${{ fromJSON(env.java-build-paths) }}
if: vars.analyze_java && (github.ref_name == 'main' || needs.check-changes.outputs.java == 'true')
strategy:
fail-fast: false
matrix:
build-path: ${{ fromJSON(vars.java_build_paths) }}
🧰 Tools
🪛 actionlint (1.7.4)

69-69: context "env" is not allowed here. available contexts are "github", "inputs", "needs", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details

(expression)


73-73: context "env" is not allowed here. available contexts are "github", "inputs", "needs", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details

(expression)

🪛 YAMLlint (1.35.1)

[error] 71-71: wrong indentation: expected 10 but found 6

(indentation)


[error] 73-73: wrong indentation: expected 12 but found 8

(indentation)

@hupling hupling marked this pull request as ready for review March 6, 2025 14:05
@hupling
Copy link
Contributor Author

hupling commented Mar 6, 2025

@ffmuc please review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor Codeql Action and Workflows
1 participant