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

Fix audit verifier action test #947

Closed
wants to merge 74 commits into from
Closed

Conversation

0xDEnYO
Copy link
Contributor

@0xDEnYO 0xDEnYO commented Jan 23, 2025

Which Jira task belongs to this PR?

Why did I implement it this way?

Checklist before requesting a review

Checklist for reviewer (DO NOT DEPLOY and contracts BEFORE CHECKING THIS!!!)

  • I have checked that any arbitrary calls to external contracts are validated and or restricted
  • I have checked that any privileged calls (i.e. storage modifications) are validated and or restricted
  • I have ensured that any new contracts have had AT A MINIMUM 1 preliminary audit conducted on by <company/auditor>

Copy link
Contributor

coderabbitai bot commented Jan 23, 2025

Warning

Rate limit exceeded

@0xDEnYO has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 21 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 aff484f and cf00d50.

📒 Files selected for processing (1)
  • src/Facets/NewContract.sol (1 hunks)

Walkthrough

The pull request introduces a consistent approach to managing workflow control across multiple GitHub Actions workflows by adding an environment variable CONTINUE. This variable is typically initialized to false and set to true based on specific conditions, such as retrieving team members, detecting modified files, or validating specific criteria. The changes enhance workflow control flow, error handling, and execution logic across various GitHub Actions workflows, including those related to security, auditing, and version checking. A new variable AUDIT_REQUIRED is also introduced in the audit verification workflow.

Changes

File Change Summary
.github/workflows/ensureSCCoreDevApproval.yml, .github/workflows/protectAuditLabels.yml, .github/workflows/protectSecurityRelevantCode.yml, .github/workflows/versionCheck.yml, .github/workflows_deactivated/ensureDeployProcessIntegrity.yml, .github/workflows_deactivated/protectAuditFolder.yml Added CONTINUE environment variable with initialization and conditional logic for workflow control.
.github/workflows/verifyAudit.yml Introduced AUDIT_REQUIRED environment variable, removed CONTINUE variable for simplified logic.
src/Facets/AcrossFacetV3.sol Updated title comment and version from 1.1.0 to 1.2.0.
.github/workflows_deactivated/ensureSCCoreDevApproval.yml, .github/workflows_deactivated/protectAuditCompletedLabel.yml, .github/workflows_deactivated/enforceTestCoverage.yml, .github/workflows_deactivated/protectAuditLabels.yml Deleted workflows related to PR review process, audit label protection, test coverage enforcement, and audit completion.
.github/workflows/versionControlAndAuditVerification.yml New workflow added to manage version control checks and audit verification for Solidity contracts.

Possibly related PRs

Suggested labels

AuditRequired

Suggested reviewers

  • ezynda3
  • 0xDEnYO

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

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: 1

🔭 Outside diff range comments (2)
.github/workflows_deactivated/ensureDeployProcessIntegrity.yml (1)

Line range hint 92-93: Security Issue: Incorrect group name assignment.

The commented line shows the correct group name 'information-security-manager', but the actual assignment uses 'smart-contract-core'. This could lead to incorrect permission checks.

Apply this fix:

-          # GROUP_NAME='information-security-manager'
-          GROUP_NAME='smart-contract-core'
+          GROUP_NAME='information-security-manager'
.github/workflows/protectSecurityRelevantCode.yml (1)

Line range hint 84-85: Security Enhancement: Improve GitHub CLI authentication error handling.

The current implementation could expose the token in error messages. Consider using a more secure approach.

Apply this improvement:

-          gh auth login --with-token < <(echo "$GH_PAT") || { echo "Failed to login with GitHub CLI"; exit 1; }
+          if ! gh auth login --with-token < <(echo "$GH_PAT" 2>/dev/null); then
+            echo "Failed to authenticate with GitHub CLI"
+            exit 1
+          fi
🧹 Nitpick comments (2)
.github/workflows/versionCheck.yml (1)

Line range hint 49-50: Consider using exit 0 for expected failures.

When no files are found, this is an expected failure case. Consider using exit 0 instead of exit 1 to indicate that the workflow completed successfully but found no work to do.

-            echo "CONTINUE=false" >> "$GITHUB_ENV" # explicit assignment, even though already initialized with false
-            exit 1
+            echo "CONTINUE=false" >> "$GITHUB_ENV" # explicit assignment, even though already initialized with false
+            exit 0
.github/workflows/verifyAudit.yml (1)

173-173: Consider consolidating CONTINUE variable assignments.

The step sets CONTINUE=false twice: once implicitly through the condition and once explicitly in the script. Consider removing the explicit assignment since the condition already handles this case.

-          # set CONTINUE to false to ensure that action fails (correctly) if an error occurs unexpectedly
-          echo "CONTINUE=false" >> "$GITHUB_ENV"

Also applies to: 179-181

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e3134f7 and 44cb7fa.

📒 Files selected for processing (11)
  • .github/workflows/ensureSCCoreDevApproval.yml (1 hunks)
  • .github/workflows/protectAuditLabels.yml (1 hunks)
  • .github/workflows/protectSecurityRelevantCode.yml (1 hunks)
  • .github/workflows/verifyAudit.yml (7 hunks)
  • .github/workflows/versionCheck.yml (1 hunks)
  • .github/workflows_deactivated/enforceTestCoverage.yml (0 hunks)
  • .github/workflows_deactivated/ensureDeployProcessIntegrity.yml (1 hunks)
  • .github/workflows_deactivated/ensureSCCoreDevApproval.yml (0 hunks)
  • .github/workflows_deactivated/protectAuditCompletedLabel.yml (0 hunks)
  • .github/workflows_deactivated/protectAuditFolder.yml (1 hunks)
  • audit/auditLog.json (1 hunks)
💤 Files with no reviewable changes (3)
  • .github/workflows_deactivated/enforceTestCoverage.yml
  • .github/workflows_deactivated/protectAuditCompletedLabel.yml
  • .github/workflows_deactivated/ensureSCCoreDevApproval.yml
✅ Files skipped from review due to trivial changes (1)
  • audit/auditLog.json
🧰 Additional context used
📓 Learnings (4)
📓 Common learnings
Learnt from: 0xDEnYO
PR: lifinance/contracts#921
File: .github/workflows/ensureSCCoreDevApproval.yml:20-20
Timestamp: 2025-01-16T03:34:05.229Z
Learning: In GitHub Actions workflows for lifinance/contracts repository, it is acceptable to declare the CONTINUE environment variable at the workflow level (within individual steps) rather than at the job level.
.github/workflows/versionCheck.yml (1)
Learnt from: 0xDEnYO
PR: lifinance/contracts#921
File: .github/workflows/ensureSCCoreDevApproval.yml:20-20
Timestamp: 2025-01-16T03:34:05.229Z
Learning: In GitHub Actions workflows for lifinance/contracts repository, it is acceptable to declare the CONTINUE environment variable at the workflow level (within individual steps) rather than at the job level.
.github/workflows/ensureSCCoreDevApproval.yml (1)
Learnt from: 0xDEnYO
PR: lifinance/contracts#921
File: .github/workflows/ensureSCCoreDevApproval.yml:20-20
Timestamp: 2025-01-16T03:34:05.229Z
Learning: In GitHub Actions workflows for lifinance/contracts repository, it is acceptable to declare the CONTINUE environment variable at the workflow level (within individual steps) rather than at the job level.
.github/workflows_deactivated/ensureDeployProcessIntegrity.yml (1)
Learnt from: 0xDEnYO
PR: lifinance/contracts#921
File: .github/workflows/ensureSCCoreDevApproval.yml:20-20
Timestamp: 2025-01-16T03:34:05.229Z
Learning: In GitHub Actions workflows for lifinance/contracts repository, it is acceptable to declare the CONTINUE environment variable at the workflow level (within individual steps) rather than at the job level.
🪛 actionlint (1.7.4)
.github/workflows/verifyAudit.yml

174-174: shellcheck reported issue in this script: SC2034:warning:12:1: COMMIT_HASHES_FILE appears unused. Verify use (or export if used externally)

(shellcheck)


174-174: shellcheck reported issue in this script: SC2034:warning:13:1: AUDITOR_GIT_HANDLES_FILE appears unused. Verify use (or export if used externally)

(shellcheck)


174-174: shellcheck reported issue in this script: SC2027:warning:125:94: The surrounding quotes actually unquote this. Remove or escape them

(shellcheck)


174-174: shellcheck reported issue in this script: SC2086:info:125:94: Double quote to prevent globbing and word splitting

(shellcheck)


174-174: shellcheck reported issue in this script: SC2086:info:162:19: Double quote to prevent globbing and word splitting

(shellcheck)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: enforce-min-test-coverage
  • GitHub Check: run-unit-tests
  • GitHub Check: analyze
  • GitHub Check: generate-tag
🔇 Additional comments (8)
.github/workflows_deactivated/protectAuditFolder.yml (1)

18-19: LGTM! Environment variable initialization is consistent with team practices.

The initialization of the CONTINUE variable follows the established pattern and properly controls the workflow execution.

.github/workflows/protectAuditLabels.yml (1)

18-19: LGTM! Environment variable initialization is consistent.

The initialization of the CONTINUE variable aligns with the team's practices and effectively controls the workflow execution.

.github/workflows/ensureSCCoreDevApproval.yml (1)

15-16: LGTM! Implementation aligns with established team practices.

Based on the retrieved learning from PR #921, the initialization of the CONTINUE variable at the workflow level is the accepted practice in this repository.

.github/workflows_deactivated/ensureDeployProcessIntegrity.yml (1)

14-15: LGTM! Environment variable initialization is consistent.

The initialization of the CONTINUE variable follows the established pattern.

.github/workflows/protectSecurityRelevantCode.yml (1)

16-17: LGTM! Environment variable initialization is consistent.

The initialization of the CONTINUE variable follows the established pattern.

.github/workflows/versionCheck.yml (1)

21-22: LGTM! Good practice initializing the CONTINUE variable at job level.

The initialization of CONTINUE to false at the job level ensures consistent variable state across all steps.

.github/workflows/verifyAudit.yml (2)

28-28: LGTM! Good practice initializing the CONTINUE variable at job level.

The initialization of CONTINUE to false at the job level ensures consistent variable state across all steps.


398-398: LGTM! Good use of always() with CONTINUE variable.

The combination of always() with the CONTINUE variable ensures robust execution flow, particularly in error scenarios.

Also applies to: 409-409, 416-416


- name: Check Audit Log
continue-on-error: true
id: check-audit-log
if: env.AUDIT_REQUIRED == 'true'
if: ${{ always() && env.AUDIT_REQUIRED == 'true' && env.CONTINUE == 'true' }} # always() ensures that validation is always executed, even if env variable is not set
run: |
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

Fix unused variables and quoting issues.

Static analysis identified several issues:

  1. Unused variables: COMMIT_HASHES_FILE and AUDITOR_GIT_HANDLES_FILE
  2. Quoting issues that could lead to word splitting

Apply these fixes:

-          COMMIT_HASHES_FILE="commit_hashes.txt"
-          AUDITOR_GIT_HANDLES_FILE="auditor_handles.txt"

And fix the quoting issues:

-            echo -e "\033[31mCould not find an audit report in path $AUDIT_REPORT_PATH for contract "$FILENAME".\033[0m"
+            echo -e "\033[31mCould not find an audit report in path $AUDIT_REPORT_PATH for contract \"$FILENAME\".\033[0m"

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 actionlint (1.7.4)

174-174: shellcheck reported issue in this script: SC2034:warning:12:1: COMMIT_HASHES_FILE appears unused. Verify use (or export if used externally)

(shellcheck)


174-174: shellcheck reported issue in this script: SC2034:warning:13:1: AUDITOR_GIT_HANDLES_FILE appears unused. Verify use (or export if used externally)

(shellcheck)


174-174: shellcheck reported issue in this script: SC2027:warning:125:94: The surrounding quotes actually unquote this. Remove or escape them

(shellcheck)


174-174: shellcheck reported issue in this script: SC2086:info:125:94: Double quote to prevent globbing and word splitting

(shellcheck)


174-174: shellcheck reported issue in this script: SC2086:info:162:19: Double quote to prevent globbing and word splitting

(shellcheck)

@0xDEnYO 0xDEnYO marked this pull request as ready for review January 23, 2025 05:04
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: 2

🔭 Outside diff range comments (2)
src/Facets/DiamondCutFacet.sol (1)

Line range hint 10-10: Update contract version.

The contract was modified but the version tag was not updated. Please update the @custom:version tag to reflect the changes.

-/// @custom:version 1.0.0
+/// @custom:version 1.0.1
🧰 Tools
🪛 GitHub Actions: Version Control Checker

[error] Contract was modified but version tag was not updated. Please update the contract's version to reflect the changes.

src/Facets/AcrossFacetV3.sol (1)

Line range hint 15-15: Update contract version.

The contract was modified but the version tag was not updated. Please update the @custom:version tag to reflect the changes.

-/// @custom:version 1.1.0
+/// @custom:version 1.1.1
🧰 Tools
🪛 GitHub Actions: Version Control Checker

[error] Contract was modified but version tag was not updated. Please update the contract's version to reflect the changes.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 44cb7fa and 29209c2.

📒 Files selected for processing (2)
  • src/Facets/AcrossFacetV3.sol (1 hunks)
  • src/Facets/DiamondCutFacet.sol (1 hunks)
🧰 Additional context used
📓 Learnings (1)
📓 Common learnings
Learnt from: 0xDEnYO
PR: lifinance/contracts#921
File: .github/workflows/ensureSCCoreDevApproval.yml:20-20
Timestamp: 2025-01-16T03:34:05.229Z
Learning: In GitHub Actions workflows for lifinance/contracts repository, it is acceptable to declare the CONTINUE environment variable at the workflow level (within individual steps) rather than at the job level.
🪛 GitHub Actions: Version Control Checker
src/Facets/DiamondCutFacet.sol

[error] Contract was modified but version tag was not updated. Please update the contract's version to reflect the changes.

src/Facets/AcrossFacetV3.sol

[error] Contract was modified but version tag was not updated. Please update the contract's version to reflect the changes.

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: enforce-min-test-coverage
  • GitHub Check: protect_audit_labels
  • GitHub Check: check-version
  • GitHub Check: run-unit-tests
  • GitHub Check: verify-audit
  • GitHub Check: analyze
  • GitHub Check: generate-tag

src/Facets/DiamondCutFacet.sol Outdated Show resolved Hide resolved
src/Facets/AcrossFacetV3.sol Outdated Show resolved Hide resolved
@lifi-action-bot lifi-action-bot changed the title Fix audit verifier action test Fix audit verifier action test [AcrossFacetV3 v1.2.0] Jan 23, 2025
@lifi-action-bot lifi-action-bot changed the title Fix audit verifier action test [AcrossFacetV3 v1.2.0] Fix audit verifier action test [AmarokFacetPacked v1.1.0] Jan 23, 2025
@lifi-action-bot lifi-action-bot changed the title Fix audit verifier action test [AmarokFacetPacked v1.1.0] Fix audit verifier action test Jan 23, 2025
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: 2

♻️ Duplicate comments (1)
.github/workflows/verifyAudit.yml (1)

306-309: ⚠️ Potential issue

Fix incorrect variable reference in commit verification.

The code uses TARGET_COMMIT but should use AUDIT_COMMIT_HASH as noted in past review comments.

Apply this fix:

-            if echo "$COMMIT_LIST" | grep -q "$TARGET_COMMIT"; then
+            if echo "$COMMIT_LIST" | grep -q "$AUDIT_COMMIT_HASH"; then
🧹 Nitpick comments (2)
.github/workflows/versionControlAndAuditCheck.yml (1)

540-581: Clean up commented code.

There's a large block of commented code related to PR review verification. Either implement this functionality or remove the commented code to maintain cleanliness.

Would you like me to help implement the PR review verification logic or should we remove this commented section?

.github/workflows/verifyAudit.yml (1)

31-31: Consider using GITHUB_TOKEN for improved security.

While using a classic PAT token works, consider using the built-in GITHUB_TOKEN with fine-grained permissions for improved security. This would require:

  1. Defining necessary permissions in the workflow
  2. Using secrets.GITHUB_TOKEN instead of secrets.GIT_ACTIONS_BOT_PAT_CLASSIC
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 565790c and aff484f.

📒 Files selected for processing (6)
  • .github/workflows/verifyAudit.yml (7 hunks)
  • .github/workflows/versionCheck.yml (1 hunks)
  • .github/workflows/versionControlAndAuditCheck.yml (1 hunks)
  • src/Facets/AcrossFacetV3.sol (1 hunks)
  • src/Facets/AllBridgeFacet.sol (1 hunks)
  • src/Facets/AmarokFacet.sol (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • src/Facets/AmarokFacet.sol
  • src/Facets/AllBridgeFacet.sol
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/Facets/AcrossFacetV3.sol
  • .github/workflows/versionCheck.yml
🧰 Additional context used
📓 Learnings (1)
📓 Common learnings
Learnt from: 0xDEnYO
PR: lifinance/contracts#921
File: .github/workflows/ensureSCCoreDevApproval.yml:20-20
Timestamp: 2025-01-16T03:34:05.229Z
Learning: In GitHub Actions workflows for lifinance/contracts repository, it is acceptable to declare the CONTINUE environment variable at the workflow level (within individual steps) rather than at the job level.
🪛 actionlint (1.7.4)
.github/workflows/versionControlAndAuditCheck.yml

45-45: shellcheck reported issue in this script: SC2086:info:31:28: Double quote to prevent globbing and word splitting

(shellcheck)


45-45: shellcheck reported issue in this script: SC2086:info:35:27: Double quote to prevent globbing and word splitting

(shellcheck)


89-89: shellcheck reported issue in this script: SC2086:info:84:28: Double quote to prevent globbing and word splitting

(shellcheck)


185-185: shellcheck reported issue in this script: SC2001:style:11:14: See if you can use ${variable//search/replace} instead

(shellcheck)


185-185: shellcheck reported issue in this script: SC2086:info:35:48: Double quote to prevent globbing and word splitting

(shellcheck)


185-185: shellcheck reported issue in this script: SC2086:info:36:27: Double quote to prevent globbing and word splitting

(shellcheck)


185-185: shellcheck reported issue in this script: SC2086:info:39:28: Double quote to prevent globbing and word splitting

(shellcheck)


386-386: shellcheck reported issue in this script: SC2027:warning:111:94: The surrounding quotes actually unquote this. Remove or escape them

(shellcheck)


386-386: shellcheck reported issue in this script: SC2086:info:111:94: Double quote to prevent globbing and word splitting

(shellcheck)


386-386: shellcheck reported issue in this script: SC2086:info:145:19: Double quote to prevent globbing and word splitting

(shellcheck)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: enforce-min-test-coverage
  • GitHub Check: run-unit-tests
  • GitHub Check: analyze
🔇 Additional comments (8)
.github/workflows/versionControlAndAuditCheck.yml (2)

1-30: LGTM! The workflow configuration is well-structured.

The workflow name is correctly spelled, and the trigger events are appropriate for the intended functionality.


257-596: LGTM! The audit verification logic is well-implemented.

The audit verification job:

  1. Properly manages protected labels
  2. Verifies audit log entries
  3. Validates audit report paths
  4. Checks auditor GitHub handles
  5. Verifies commit hashes

This implementation addresses the previous concerns about missing audit verification logic.

🧰 Tools
🪛 actionlint (1.7.4)

386-386: shellcheck reported issue in this script: SC2027:warning:111:94: The surrounding quotes actually unquote this. Remove or escape them

(shellcheck)


386-386: shellcheck reported issue in this script: SC2086:info:111:94: Double quote to prevent globbing and word splitting

(shellcheck)


386-386: shellcheck reported issue in this script: SC2086:info:145:19: Double quote to prevent globbing and word splitting

(shellcheck)

.github/workflows/verifyAudit.yml (6)

28-28: LGTM! Environment variable declaration follows repository conventions.

The AUDIT_REQUIRED environment variable is correctly declared at the job level, which aligns with the repository's conventions as noted in the retrieved learnings.


38-47: LGTM! Proactive label cleanup ensures accuracy.

The new step to remove the "AuditCompleted" label at the start of the workflow is a good practice. It prevents false positives by ensuring the label is only present when all current checks pass.


59-59: Early exit improves workflow efficiency.

Good practice to exit early when no files are found, preventing unnecessary processing.


166-166: LGTM! Robust condition handling.

Using always() with the environment variable check ensures consistent validation execution, preventing potential skip scenarios.


374-374: LGTM! Conditional label assignment.

The condition if: ${{ env.AUDIT_REQUIRED == 'true' }} correctly ensures the "AuditCompleted" label is only assigned when an audit is required and all checks pass.


17-17: Consider expanding PR trigger events.

The workflow currently only triggers on PR 'opened' event. This might miss subsequent changes that could require re-verification of the audit status.

Consider adding more event types like 'synchronize' (triggered when new commits are pushed) and 'reopened' to ensure continuous audit verification:

-    types: [opened]
+    types: [opened, synchronize, reopened]

echo "" > contracts_for_audit.txt

##### get all files modified by this PR
FILES=$(git diff --name-only "origin/${BASE_REF}" HEAD)
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

Fix shell script quoting issues.

Several shell script commands need proper quoting to prevent globbing and word splitting issues.

Apply these fixes:

  1. Quote the redirection in the while loop
  2. Quote variables in echo commands
  3. Quote the file path in cat command
-          echo -e "$CONTRACTS" > modified_contracts.txt
+          echo -e "${CONTRACTS}" > modified_contracts.txt

-          CONTRACTS=$(cat modified_contracts.txt)
+          CONTRACTS=$(cat "modified_contracts.txt")

-          while IFS= read -r FILE_PATH; do
+          while IFS= read -r FILE_PATH; do
             echo "Now checking contract: ${FILE_PATH}"
             VERSION_TAG=$(grep -E '^/// @custom:version' "${FILE_PATH}" || true)
             VERSION=$(echo "${VERSION_TAG}" | sed -E 's/^\/\/\/ @custom:version ([0-9]+\.[0-9]+\.[0-9]+).*$/\1/' || true)

Also applies to: 65-69, 84-84, 92-92, 103-138

COMMIT_LIST=$(gh pr view "$PR_NUMBER" --json commits --jq '.commits[].oid')

##### Check if the target commit is in the list
if echo "$COMMIT_LIST" | grep -q "$TARGET_COMMIT"; then
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix undefined variable reference.

The variable TARGET_COMMIT is used but not defined. This will cause the script to fail.

Apply this diff to fix the issue:

-            if echo "$COMMIT_LIST" | grep -q "$TARGET_COMMIT"; then
+            if echo "$COMMIT_LIST" | grep -q "$AUDIT_COMMIT_HASH"; then
📝 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 echo "$COMMIT_LIST" | grep -q "$TARGET_COMMIT"; then
if echo "$COMMIT_LIST" | grep -q "$AUDIT_COMMIT_HASH"; then

@0xDEnYO 0xDEnYO closed this Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants