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

Remove quarantine attribute from bindings + compiled binary #3118

Merged
merged 6 commits into from
Dec 15, 2023

Conversation

leaanthony
Copy link
Member

@leaanthony leaanthony commented Dec 11, 2023

Description

Some people experience an error when generating bindings related to the temporary binary having the quarantine attribute set. This unsets it.

Summary by CodeRabbit

  • New Features

    • For macOS users, the application now automatically removes the quarantine attribute from files, streamlining the setup process.
  • Refactor

    • Enhanced platform-specific operations within the application build process for improved compatibility on macOS systems.

Copy link
Contributor

coderabbitai bot commented Dec 11, 2023

Walkthrough

The recent changes involve adding a new conditional operation in two Go source files that specifically targets macOS systems. When the code is executed on a macOS machine, it now includes a step to remove the quarantine attribute from a file. This is a security feature in macOS that can prevent files from opening or running if they were downloaded from the internet. The changes ensure compatibility with macOS by removing this attribute during the build and binding generation processes.

Changes

File Path Change Summary
v2/pkg/commands/bindings/bindings.go
v2/pkg/commands/build/build.go
Introduces conditional blocks to remove the quarantine attribute from a file on macOS within the GenerateBindings function and the execBuildApplication function.

🐇✨
In the realm of code, where the rabbits hop,
A tweak was made, a small but crucial drop.
For the Macs, a spell to unbind,
Files once quarantined, now free to unwind. 🍏💻
🐇✨

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 X ?


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can reply to a review comment made by CodeRabbit.
  • You can tag CodeRabbit on specific lines of code or files in the PR by tagging @coderabbitai in a comment.
  • You can tag @coderabbitai in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between aa8cd7c and ca404e0.
Files selected for processing (2)
  • v2/pkg/commands/bindings/bindings.go (1 hunks)
  • v2/pkg/commands/build/build.go (1 hunks)
Additional comments: 2
v2/pkg/commands/bindings/bindings.go (1)
  • 60-66: The addition of the macOS-specific code to remove the quarantine attribute from the binary using xattr -rc is correct and aligns with the PR's objective. The error handling is consistent with the rest of the function, which is good practice. Ensure that this change has been tested on macOS to confirm that it behaves as expected and does not introduce any side effects.
v2/pkg/commands/build/build.go (1)
  • 324-332: The addition of the conditional block to remove the quarantine attribute on macOS looks correct and aligns with the PR's objective. It's important to ensure that the options.CompiledBinary variable contains the correct path to the binary that needs the attribute removed. Additionally, the error handling and verbosity checks are in place, which is good practice.

v2/pkg/commands/build/build.go Outdated Show resolved Hide resolved
Copy link

cloudflare-workers-and-pages bot commented Dec 11, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5e38e13
Status: ✅  Deploy successful!
Preview URL: https://4756d81c.wails.pages.dev
Branch Preview URL: https://v2-remove-quarantine-attribu.wails.pages.dev

View logs

leaanthony and others added 3 commits December 12, 2023 20:37
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between ca404e0 and c38c81f.
Files selected for processing (1)
  • v2/pkg/commands/build/build.go (1 hunks)
Additional comments: 1
v2/pkg/commands/build/build.go (1)
  • 324-337: The changes introduced in this hunk are well-implemented and align with the PR's objective to remove the quarantine attribute from the compiled binary on macOS. The checks for the existence of the file and verbosity level are correctly placed, and the error handling is appropriate. The code is modular, maintainable, and follows best practices.

This commit adjusts the formatting in a line of code that handles a missing binary error message. Additionally, it removes a redundant closing brace that was incorrectly situated in the code, thereby cleaning up the code structure.
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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c38c81f and 5e38e13.
Files selected for processing (1)
  • v2/pkg/commands/build/build.go (1 hunks)
Additional comments: 1
v2/pkg/commands/build/build.go (1)
  • 324-336: The changes introduced to remove the quarantine attribute from the compiled binary on macOS are correctly checking for the binary's existence before attempting to remove the attribute. This is a good practice to prevent errors from non-existent files.

Comment on lines +329 to +331
stdout, stderr, err := shell.RunCommand(options.BinDirectory, "xattr", "-rc", options.CompiledBinary)
if err != nil {
return "", fmt.Errorf("%s - %s", err.Error(), stderr)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider handling the case where the xattr command might not be available on the system. This could be done by checking the error message for a "command not found" type of error and providing a more user-friendly message or documentation reference.

@leaanthony leaanthony merged commit 772f021 into master Dec 15, 2023
12 checks passed
@leaanthony leaanthony deleted the v2/remove-quarantine-attribute branch December 15, 2023 09:26
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.

2 participants