Skip to content

Staging#5

Merged
zkbkb merged 29 commits intomainfrom
staging
Jul 26, 2025
Merged

Staging#5
zkbkb merged 29 commits intomainfrom
staging

Conversation

@zkbkb
Copy link
Copy Markdown
Owner

@zkbkb zkbkb commented Jul 26, 2025

PR Type

Enhancement


Description

  • Enhanced CI/CD workflows with comprehensive testing and release automation

  • Added versioning support with build-time version injection

  • Introduced test release script for local verification

  • Updated dependencies and improved linting configuration


Diagram Walkthrough

flowchart LR
  A["Version Variable"] --> B["Build System"]
  B --> C["Test Release Script"]
  C --> D["CI Workflows"]
  D --> E["Production Release"]
  F["ESLint Config"] --> D
  G["Dependencies"] --> B
Loading

File Walkthrough

Relevant files

zkbkb and others added 24 commits July 26, 2025 08:07
…port

- Added new dependencies in go.mod
- Updated README with new badges for version and release status
- Introduced a version variable in main.go for build-time versioning
- Created a test-release.sh script for verifying builds and dependencies
- Enhanced GitHub Actions workflow to include verification steps for Node.js and Go before release
- Introduced a new test_release.yml workflow for verifying builds and testing releases.
- Introduced a new GitHub Actions workflow for testing builds, including Node.js and Go verification, linting, and security scanning.
- Changed the release badge in README to point to the production release workflow.
Fix (`test_build.yml`) to automatically validate code and build on every push and pull request.

The new workflow performs the following checks:
- Builds and tests both the Go and Node.js applications across multiple platforms (Linux, macOS, Windows).
- Lints Go and JavaScript code to ensure style consistency.
- Verifies Go module integrity and performs security scans with Trivy.
- Implements concurrency control to cancel redundant checks on rapid pushes, keeping the CI queue clean.

Additionally, this commit includes:
- A new "Test Build" status badge in `README.md` for immediate feedback on code health.
- A fix for the existing "Release" badge, pointing it to the correct `production_release.yml` workflow.
Co-authored-by: zzkbkbb <zzkbkbb@gmail.com>
Co-authored-by: zzkbkbb <zzkbkbb@gmail.com>
Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>
Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>
Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>
Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>
…rkflows-36ca

Refactor and unify testing workflows
Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>
Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>
Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>
Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* fix: address security vulnerabilities and code quality issues

- Fix command injection vulnerability in test-release.sh by adding -- separator for exec
- Add input validation to prevent malicious arguments in test-release.sh
- Make Version variable immutable by using GetVersion() function
- Fix inconsistent quote style in index.mjs comments

* fix: CI workflow shell formatting and .gitignore cleanup

- Fix broken shell line continuation in test_release.yml go build commands
- Remove excessive whitespace in go build commands (lines 103-104, 158-159)
- Use proper line continuation syntax with backslashes
- Remove redundant test-build/* line from .gitignore

* Update test-release.sh

Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>

* Update main.go

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Update main.go

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* fix: update ldflags to use lowercase 'main.version' variable

Updated all build commands in GitHub workflows to reference main.version instead of main.Version to match the renamed variable in main.go

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @zkbkb, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the project's development and release infrastructure. I've integrated ESLint to enforce code quality standards for JavaScript, introduced a robust shell script for automated release testing and cross-platform builds, and updated the README with informative status badges. These changes collectively aim to streamline our development workflow, improve code maintainability, and ensure the reliability of future releases.

Highlights

  • Code Quality and Linting: I've introduced ESLint to the project, adding a new .eslintrc.json configuration and corresponding lint scripts in package.json. This will help maintain code quality and consistency across the JavaScript/Node.js codebase.
  • Automated Release Testing and CI/CD Improvements: I've added a comprehensive test-release.sh script that automates environment checks, verifies dependency consistency for both Node.js and Go modules, and performs cross-platform builds. This significantly enhances our release validation process.
  • Project Visibility and Status Badges: I've updated the README.md with new badges to prominently display the status of our GitHub Actions workflows, latest releases, and npm package version. This provides quick visual feedback on the project's health and distribution.
  • Performance Optimization for Repository Scanning: I've refined the repository scanning logic in index.mjs by expanding the list of directories to skip, such as target, build, and dist. This optimization will improve the performance of the git-status-dash tool by avoiding unnecessary scans of generated or dependency-heavy folders.
  • Go Module Updates and Versioning: I've updated the Go module dependencies in go.mod and go.sum, ensuring that our Go backend components are using the latest compatible versions. Additionally, I've implemented proper versioning for the Go executable in main.go, allowing it to report its version.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review bot commented Jul 26, 2025

PR Reviewer Guide 🔍

(Review updated until commit bc36ba6)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 No relevant tests
🔒 Security concerns

Command injection vulnerabilities:
The test-release.sh script contains multiple instances where user input and environment variables are used directly in shell commands without proper sanitization. Specifically: 1) The exec calls on lines 20-24 use user arguments that could contain shell metacharacters despite basic validation, 2) Command substitution on lines 250-302 uses variables like $GO_EXECUTABLE and version strings directly in go build commands, 3) The script uses eval-like constructs with node -p commands that could be exploited if package.json is malicious. These could allow arbitrary command execution if an attacker can control the input or environment.

⚡ Recommended focus areas for review

Security Risk

The shell script performs argument validation but then uses exec with user-provided arguments. The validation regex may not catch all dangerous patterns, and the exec calls could potentially be exploited through shell injection if the validation is bypassed.

    SHELL_REEXEC_GUARD=1 exec zsh -- "$0" "$@"
elif command -v bash >/dev/null 2>&1; then
    # Validate and escape arguments before passing to exec
    # Use -- to prevent argument injection
    SHELL_REEXEC_GUARD=1 exec bash -- "$0" "$@"
Command Injection

Multiple locations use unvalidated command substitution and variable expansion in shell commands. Variables like GO_EXECUTABLE and version strings are used directly in command execution without proper escaping.

if $GO_EXECUTABLE build -ldflags="-s -w -X main.version=$(node -p \"require('./package.json').version\")" -o "test-build/git-status-dash-go-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m)" .; then
    echo "[${GREEN}${NC}] Native binary built successfully"

    # Create symlink for consistent testing
    ln -sf "git-status-dash-go-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m)" "test-build/git-status-dash"
    echo "[${GREEN}${NC}] Created symlink: test-build/git-status-dash"

    # Test the binary
    echo "${LIGHT_BLUE}Testing binary functionality...${NC}"
    local test_failed=false
    if ./test-build/git-status-dash --version >/dev/null 2>&1; then
        echo "[${GREEN}${NC}] Version command works"
    else
        echo "[${RED}${NC}] Version command failed"
        test_failed=true
    fi

    if ./test-build/git-status-dash config init >/dev/null 2>&1; then
        echo "[${GREEN}${NC}] Config init command works"
    else
        echo "[${RED}${NC}] Config init command failed"
        test_failed=true
    fi

    if [ "$test_failed" = true ]; then
        echo "[${RED}${NC}] Binary functionality tests failed"
        BUILD_STATUS="failed"
        return 1
    fi
else
    echo "[${RED}${NC}] Native binary build failed"
    return 1
fi

# Cross-compilation test (matching release.yml)
echo "${LIGHT_BLUE}Testing cross-compilation...${NC}"
local platforms=(
    "linux/amd64"
    "linux/arm64"
    "darwin/amd64"
    "darwin/arm64"
    "windows/amd64"
)
local success_count=0

for platform in "${platforms[@]}"; do
    IFS='/' read -r os arch <<< "$platform"
    local output_name="test-build/git-status-dash-go-${os}-${arch}"
    if [ "$os" = "windows" ]; then
        output_name="${output_name}.exe"
    fi

    if GOOS="$os" GOARCH="$arch" $GO_EXECUTABLE build -ldflags="-s -w -X main.version=$(node -p \"require('./package.json').version\")" -o "$output_name" .; then
Global Variable

The version variable is declared as a global mutable variable but documented as immutable. This could lead to unexpected behavior if the variable is modified elsewhere in the codebase.

// Version is set at build time via ldflags
var version = "dev"

// GetVersion returns the application version (immutable)
func GetVersion() string {
	return version
}

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review bot commented Jul 26, 2025

PR Code Suggestions ✨

Latest suggestions up to bc36ba6
Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Prevent infinite shell re-execution loops

The shell re-execution logic creates potential for infinite loops if
SHELL_REEXEC_GUARD gets unset or if the exec fails silently. Add a counter or
additional safeguards to prevent infinite re-execution attempts.

test-release.sh [14-29]

 # Smart shell detection: try zsh first, then bash
 if [ -z "${BASH_VERSION}" ] && [ -z "${ZSH_VERSION}" ] && [ -z "${SHELL_REEXEC_GUARD}" ]; then
+    # Prevent infinite re-execution
+    if [ "${SHELL_REEXEC_COUNT:-0}" -gt 2 ]; then
+        echo "Error: Too many shell re-execution attempts"
+        exit 1
+    fi
     # We're in a basic shell, try to find zsh or bash
     if command -v zsh >/dev/null 2>&1; then
-        # Validate and escape arguments before passing to exec
-        # Use -- to prevent argument injection
-        SHELL_REEXEC_GUARD=1 exec zsh -- "$0" "$@"
+        SHELL_REEXEC_GUARD=1 SHELL_REEXEC_COUNT=$((${SHELL_REEXEC_COUNT:-0} + 1)) exec zsh -- "$0" "$@"
     elif command -v bash >/dev/null 2>&1; then
-        # Validate and escape arguments before passing to exec
-        # Use -- to prevent argument injection
-        SHELL_REEXEC_GUARD=1 exec bash -- "$0" "$@"
+        SHELL_REEXEC_GUARD=1 SHELL_REEXEC_COUNT=$((${SHELL_REEXEC_COUNT:-0} + 1)) exec bash -- "$0" "$@"
     else
         echo "Error: Neither zsh nor bash found. Please install one of them."
         exit 1
     fi
 fi
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies a potential infinite loop in the shell re-execution logic and provides a robust solution using a counter, improving the script's reliability.

Medium
Security
Refine argument validation pattern

The character validation pattern is overly restrictive and may prevent
legitimate use cases. Characters like parentheses, quotes, and asterisks are
commonly used in valid file paths and arguments. Consider validating only truly
dangerous patterns or use proper argument escaping instead.

test-release.sh [3-12]

-# Validate input arguments
+# Validate input arguments for dangerous patterns
 for arg in "$@"; do
-    # Check for potentially dangerous characters
+    # Check for command injection patterns
     case "$arg" in
-        *[\;\|\&\$\`\(\)\<\>\'\"\*\?]*)
-            echo "Error: Invalid characters in arguments"
+        *[\;\|\&\$\`]*|*"$("|*")"*)
+            echo "Error: Potentially dangerous characters in arguments"
             exit 1
             ;;
     esac
 done
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies that the argument validation is overly restrictive and proposes a more precise pattern, improving the script's robustness for valid inputs.

Low
  • More

Previous suggestions

✅ Suggestions up to commit 6f0ddaf
CategorySuggestion                                                                                                                                    Impact
Possible issue
Prevent infinite shell re-execution
Suggestion Impact:The suggestion was directly implemented - the guard variable SHELL_REEXEC_GUARD was added to the condition check and set when re-executing with zsh or bash

code diff:

-if [ -z "${BASH_VERSION}" ] && [ -z "${ZSH_VERSION}" ]; then
+if [ -z "${BASH_VERSION}" ] && [ -z "${ZSH_VERSION}" ] && [ -z "${SHELL_REEXEC_GUARD}" ]; then
     # We're in a basic shell, try to find zsh or bash
     if command -v zsh >/dev/null 2>&1; then
         # Validate and escape arguments before passing to exec
         # Use -- to prevent argument injection
-        exec zsh -- "$0" "$@"
+        SHELL_REEXEC_GUARD=1 exec zsh -- "$0" "$@"
     elif command -v bash >/dev/null 2>&1; then
         # Validate and escape arguments before passing to exec
         # Use -- to prevent argument injection
-        exec bash -- "$0" "$@"
+        SHELL_REEXEC_GUARD=1 exec bash -- "$0" "$@"

The shell detection logic may cause infinite recursion if the script is already
running in zsh or bash but the version variables are not set. Add a guard to
prevent re-execution and ensure the script doesn't loop indefinitely.

test-release.sh [14-29]

 # Smart shell detection: try zsh first, then bash
-if [ -z "${BASH_VERSION}" ] && [ -z "${ZSH_VERSION}" ]; then
+if [ -z "${BASH_VERSION}" ] && [ -z "${ZSH_VERSION}" ] && [ -z "${SHELL_REEXEC_GUARD}" ]; then
     # We're in a basic shell, try to find zsh or bash
     if command -v zsh >/dev/null 2>&1; then
         # Validate and escape arguments before passing to exec
         # Use -- to prevent argument injection
-        exec zsh -- "$0" "$@"
+        SHELL_REEXEC_GUARD=1 exec zsh -- "$0" "$@"
     elif command -v bash >/dev/null 2>&1; then
         # Validate and escape arguments before passing to exec
         # Use -- to prevent argument injection
-        exec bash -- "$0" "$@"
+        SHELL_REEXEC_GUARD=1 exec bash -- "$0" "$@"
     else
         echo "Error: Neither zsh nor bash found. Please install one of them."
         exit 1
     fi
 fi

[Suggestion processed]

Suggestion importance[1-10]: 8

__

Why: This is a valid and important suggestion that adds a guard variable to prevent a potential infinite recursion edge case in the shell detection logic, making the script more robust.

Medium
Security
Refine input validation pattern

The character validation pattern is overly restrictive and may block legitimate
arguments like file paths containing spaces or special characters. Consider
using a more targeted approach that validates specific argument types or
sanitizes input instead of blanket rejection.

test-release.sh [3-12]

-# Validate input arguments
+# Validate input arguments for command injection patterns
 for arg in "$@"; do
-    # Check for potentially dangerous characters
+    # Check for command injection patterns specifically
     case "$arg" in
-        *[\;\|\&\$\`\(\)\<\>\'\"\*\?]*)
-            echo "Error: Invalid characters in arguments"
+        *[\;\|\&\$\`]*)
+            echo "Error: Potentially unsafe characters in arguments"
             exit 1
             ;;
     esac
 done
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies that the argument validation is overly restrictive and proposes a more targeted pattern, improving the script's usability while maintaining security against command injection.

Medium

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces significant improvements to the project's development and release workflow. The addition of versioning support, CI/CD workflows via a comprehensive test script, and ESLint for code quality are all excellent enhancements. My review focuses on improving the robustness of the new test script and ensuring consistency in the development environment.

.DS_Store
.vscode/
test-build/
package-lock.json No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Ignoring package-lock.json while yarn.lock is checked in can lead to inconsistent dependencies if some developers use npm and others use yarn. It's best practice to enforce a single package manager for the project to ensure reproducible builds.

To enforce yarn, you could add an engines field to your package.json to prevent accidental use of npm.

Example package.json change:

"engines": {
  "node": ">=16.0.0",
  "npm": "please-use-yarn",
  "yarn": ">= 1.22.0"
}

You could also add a preinstall script to enforce this more strictly:
"preinstall": "npx only-allow yarn"

zkbkb and others added 5 commits July 26, 2025 02:59
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>
@zkbkb zkbkb closed this Jul 26, 2025
@zkbkb zkbkb reopened this Jul 26, 2025
@zkbkb
Copy link
Copy Markdown
Owner Author

zkbkb commented Jul 26, 2025

/describe

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review bot commented Jul 26, 2025

PR Description updated to latest commit (bc36ba6)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

File Walkthrough

@zkbkb zkbkb merged commit 8257e3f into main Jul 26, 2025
3 checks passed
zkbkb added a commit that referenced this pull request Jul 26, 2025
This reverts commit 8257e3f.
@zkbkb zkbkb mentioned this pull request Jul 26, 2025
zkbkb added a commit that referenced this pull request Jul 26, 2025
This reverts commit 8257e3f.
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