Skip to content

int: changes for building arm64 binary - #493

Open
h0x0er wants to merge 1 commit into
intfrom
jatin/arm-support-int
Open

int: changes for building arm64 binary#493
h0x0er wants to merge 1 commit into
intfrom
jatin/arm-support-int

Conversation

@h0x0er

@h0x0er h0x0er commented Sep 7, 2026

Copy link
Copy Markdown
Member

No description provided.

@h0x0er h0x0er linked an issue Sep 7, 2026 that may be closed by this pull request

@step-security-bot-int step-security-bot-int 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.

Please find StepSecurity AI-CodeWise code comments below.

Code Comments

.goreleaser.yml

  • [Low]Ensure consistency in file ending with a newline character
    POSIX standards recommend that text files end with a newline character to ensure compatibility with various tools and utilities. Many editors and version control systems expect files to end with a newline, and missing newline can cause unexpected diffs or issues in processing the file. Add a newline character at the end of the file. Ensure that after the last line 'linux_amd64' and 'linux_arm64', a newline exists.

Correct diff fragment:

  •  - linux_amd64
    
  •  - linux_amd64
    
  •  - linux_arm64
    

procmon_linux.go

  • [High]Handle errors returned by functions properly instead of ignoring them
    In Go, ignoring errors can lead to unexpected behavior and makes debugging difficult. The code currently ignores the errors returned by flags.Parse and rule.Build. According to the Go programming language effective practices guide (https://go.dev/doc/effective_go#errors), errors should always be checked and handled appropriately. Modify the code to check and handle the error returned by flags.Parse and rule.Build by adding proper error handling, such as logging the error or returning it through the errc channel.

Example fix:

r, err := flags.Parse(auditRule)
if err != nil {
    errc <- fmt.Errorf("failed to parse audit rule: %w", err)
    return
}
actualBytes, err := rule.Build(r)
if err != nil {
    errc <- fmt.Errorf("failed to build audit rule: %w", err)
    return
}
  • [High]Avoid hardcoding directory paths; consider making workingDirectory configurable or validated
    Hardcoding paths like /home/runner may not be valid or secure across all deployment environments. As per secure coding guidelines from OWASP (https://cheatsheetseries.owasp.org/cheatsheets/Configuration_Cheat_Sheet.html), configuration values should be externalized and validated to ensure proper security and flexibility. Allow workingDirectory to be configurable via environment variables or configuration files and validate the path before use.

Example fix:

workingDirectory := os.Getenv("WORKING_DIRECTORY")
if workingDirectory == "" {
    // Fallback default with validation
    workingDirectory = "/home/runner"
}
// Add validation code to verify workingDirectory exists and is accessible
  • [Medium]Define audit rules consistently and handle architecture-specific differences explicitly
    The patch handles ARM64 architecture differently by omitting some syscall filters, potentially altering behavior. According to the principle of least astonishment and maintainability (https://martinfowler.com/bliki/PrincipleOfLeastSurprise.html), security-sensitive code should document and clearly separate platform-specific behavior to avoid unintended side-effects. Add comments explaining why certain syscalls are omitted for ARM64 and consider defining audit rules as constants or configuration for clarity.

Example fix:

// Define audit rules per architecture
const (
    baseAuditRule = "-a exit,always -F perm=wa -k %s"
    dirAuditRule = "-F dir=%s"
    x86Syscalls = "-S open -S openat -S rename -S renameat"
    arm64Syscalls = "-S openat -S renameat"
)

var auditRule string
if runtime.GOARCH == "arm64" {
    auditRule = fmt.Sprintf("%s %s %s", baseAuditRule, fmt.Sprintf(dirAuditRule, workingDirectory), arm64Syscalls, fileMonitorTag)
} else {
    auditRule = fmt.Sprintf("%s %s %s", baseAuditRule, fmt.Sprintf(dirAuditRule, workingDirectory), x86Syscalls, fileMonitorTag)
}

Also document reasons in comments.

  • [Medium]Avoid using anonymous imports unless necessary
    In the provided snippet, imports appear normal, but adding runtime should be explicit and used purposefully. Best practice (Effective Go https://go.dev/doc/effective_go#imports) suggests imports should be necessary and minimal to reduce code bloat and maintain clarity. Ensure the newly added runtime import is used only as intended, and remove any unused imports to keep code clean.

No direct code change needed if the import is used correctly, but verify import statements are tidy.

  • [Low]Use consistent variable naming conventions and avoid shadowing
    The variable r is used to store parsing results. Using more descriptive variable names improves code readability as suggested in Clean Code by Robert C. Martin. Rename r to something more descriptive such as parsedFlags or parsedRule.

Example fix:

parsedRule, err := flags.Parse(auditRule)
if err != nil {
    errc <- fmt.Errorf("failed to parse audit rule: %w", err)
    return
}
actualBytes, err := rule.Build(parsedRule)
if err != nil {
    errc <- fmt.Errorf("failed to build audit rule: %w", err)
    return
}
  • [Low]Add logging for audit rule creation steps for better observability
    Security-sensitive code benefits from adequate audit logging to trace execution and file system monitoring setup, improving maintainability and troubleshooting (Logging Best Practices, Google SRE book). Add logs showing which audit rules are being built and used.

Example fix:

log.Printf("Creating audit rule: %s", auditRule)
// proceed with parsing and building

releasers/int.yml

  • [Low]Add a newline character at the end of the file
    POSIX standards recommend files to end with a newline character. Missing newlines can cause issues with some tools and version control systems, and may lead to unexpected behavior. Add a newline character at the end of the file to comply with POSIX standards and avoid tooling issues.

Feedback

We appreciate your feedback in helping us improve the service! To provide feedback, please use emojis on this comment. If you find the comments helpful, give them a 👍. If they aren't useful, kindly express that with a 👎. If you have questions or detailed feedback, please create n GitHub issue in StepSecurity/AI-CodeWise.

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.

add support for arm64 machines

2 participants