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

[v3] allow build with garble #3192

Open
wants to merge 4 commits into
base: v3-alpha
Choose a base branch
from
Open

Conversation

5aaee9
Copy link
Contributor

@5aaee9 5aaee9 commented Jan 10, 2024

Description

This patch make wails v3 app able to build with garble

Tested build on Windows and macOS

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using wails doctor.

  • Windows
  • macOS
  • Linux

Test Configuration

Please paste the output of wails doctor. If you are unable to run this command, please describe your environment in as much detail as possible.

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • New Features

    • Added documentation for events and templates for SvelteKit.
    • Introduced commands for updating build assets and generating runtime.
    • New options for window positioning and file associations.
    • Enhanced Windows options for autofill and password autosave.
  • Bug Fixes

    • Resolved issues with AlwaysOnTop on Mac and compilation for aarch64 on Linux.
    • Fixed garble build and duplicate roles in the edit menu for Darwin.
  • Changes

    • Refactored Taskfile and upgraded the go-webview2 library.
    • Significant updates to the Events API, including renaming and restructuring.

Copy link
Contributor

coderabbitai bot commented Jan 10, 2024

Walkthrough

The pull request introduces a series of updates to the project's changelog, documenting new features, modifications, and bug fixes. Key additions include commands for updating build assets and generating runtime, enhancements to window positioning, and improvements to the Events API. Changes also encompass a refactor of the Taskfile and updates to the go-webview2 library. Furthermore, the request includes minor adjustments in the DialogConfig and application_debug.go files to enhance type visibility and error handling, respectively.

Changes

File Path Change Summary
mkdocs-website/docs/en/changelog.md Updated changelog with sections for Added, Changed, Fixed, and Removed, detailing new features, enhancements, and bug fixes including v3.0.0-alpha.7 release.
v3/internal/go-common-file-dialog/cfd/DialogConfig.go Added import for reflect package and ensured FileFilter type visibility without altering existing logic or functionality.
v3/pkg/application/application_debug.go Enhanced error handling in logStartup method to prevent dereferencing of nil pointer when BuildInfo is nil, maintaining existing initialization logic.

Possibly related PRs

🐰 In the changelog, we now see,
New features sprouting, as bright as can be!
Commands for building, and paths to explore,
With fixes and changes, we open new doors.
So hop along, friends, let’s celebrate right,
For our project is growing, oh what a delight! 🌟


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 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.

Copy link
Member

@leaanthony leaanthony left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to open this 🙏 We will look at packaging shortly so this will help a lot.

Did you test running garble on code that uses bindings (Call.ByName) and events?

@5aaee9
Copy link
Contributor Author

5aaee9 commented Jan 11, 2024

@leaanthony

Events are working

image

But Call.ByID and Call.ByName is not able to find target method because of the obfs

@leaanthony
Copy link
Member

I think there's a bit more to do but it's fairly easy.

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 and nitpick comments (3)
v3/pkg/application/application_debug.go (2)

43-47: Consider adding minimal debug info for Garble builds.

While Garble strips debug information, it might be helpful to log a message indicating that the application was built with Garble, providing some minimal context for debugging.

Here's a suggested enhancement:

 // BuildInfo is nil when build with garble
 if BuildInfo == nil {
+    a.info("Build Info: Application built with Garble (debug information stripped)")
     return
 }

Line range hint 1-47: Address method invocation issues with Garble.

Based on the PR comments, there are issues with Call.ByID and Call.ByName not locating target methods due to Garble's obfuscation. This file handles the immediate BuildInfo issue, but the method invocation problem needs to be addressed.

Would you like me to:

  1. Generate a solution for preserving method names during Garble builds?
  2. Create a GitHub issue to track the method invocation problems?
v3/internal/go-common-file-dialog/cfd/DialogConfig.go (1)

18-19: LGTM: Type preservation is correctly implemented

The type preservation for FileFilter is implemented using the standard pattern with reflect.TypeOf. This is crucial for maintaining type information when building with Garble.

Consider documenting this pattern in a central location (e.g., developer docs) as it might be needed for other types that should not be obfuscated when using Garble. Based on the PR comments about method discovery issues, you might need to apply similar preservation techniques to other types involved in method calls like Call.ByID and Call.ByName.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 99d538e and 3505fd1.

📒 Files selected for processing (3)
  • mkdocs-website/docs/en/changelog.md (2 hunks)
  • v3/internal/go-common-file-dialog/cfd/DialogConfig.go (2 hunks)
  • v3/pkg/application/application_debug.go (1 hunks)
🔇 Additional comments (4)
v3/pkg/application/application_debug.go (1)

43-47: LGTM! Proper handling of nil BuildInfo for Garble builds.

The added nil check is essential as Garble strips debug information, making BuildInfo nil. This change prevents potential panic scenarios.

Let's verify the behavior with Garble:

v3/internal/go-common-file-dialog/cfd/DialogConfig.go (2)

6-6: LGTM: Import addition is appropriate

The reflect package import is necessary for type preservation and is correctly grouped with other standard library imports.


18-19: Verify other types that might need preservation

Let's check for other types in the codebase that might need similar preservation when using Garble.

mkdocs-website/docs/en/changelog.md (1)

Line range hint 140-152: Verify binding generator changes compatibility with Garble.

The binding generator now uses calls by ID by default, which is relevant to the known issue with Garble obfuscation affecting method targeting. This change might need additional documentation or considerations for Garble users.

Consider adding a note about Garble compatibility in this section:

 The binding generator now uses calls by ID by default. The `-id` CLI option has been removed. Use the `-names` CLI option to switch back to calls by name. By [@fbbdev](https://github.com/fbbdev) in [#3468](https://github.com/wailsapp/wails/pull/3468)
+Note: When building with Garble, method targeting through IDs may be affected by obfuscation. Additional configuration might be required.

Let's verify the impact of these changes on Garble builds:

@@ -41,7 +41,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed `AlwaysOnTop` not working on Mac by [leaanthony](https://github.com/leaanthony) in [#3841](https://github.com/wailsapp/wails/pull/3841)
- [darwin] Fixed `application.NewEditMenu` including a duplicate `PasteAndMatchStyle` role in the edit menu on Darwin by [johnmccabe](https://github.com/johnmccabe) in [#3839](https://github.com/wailsapp/wails/pull/3839)
- [linux] Fixed aarch64 compilation [#3840](https://github.com/wailsapp/wails/issues/3840) in [#3854](https://github.com/wailsapp/wails/pull/3854) by [kodflow](https://github.com/kodflow)

- Fixed garble build by @5aaee9 in [#3192](https://github.com/wailsapp/wails/pull/3192)
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

Enhance the changelog entry with more context about Garble integration.

The current entry "Fixed garble build" is too brief. Consider expanding it to provide more context about the Garble integration and known limitations:

-Fixed garble build by @5aaee9 in [#3192](https://github.com/wailsapp/wails/pull/3192)
+Added support for building with Garble (Go binary obfuscator) by @5aaee9 in [#3192](https://github.com/wailsapp/wails/pull/3192). Note: Method invocation through `Call.ByID` and `Call.ByName` may be affected by obfuscation.
📝 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
- Fixed garble build by @5aaee9 in [#3192](https://github.com/wailsapp/wails/pull/3192)
Added support for building with Garble (Go binary obfuscator) by @5aaee9 in [#3192](https://github.com/wailsapp/wails/pull/3192). Note: Method invocation through `Call.ByID` and `Call.ByName` may be affected by obfuscation.

@leaanthony
Copy link
Member

leaanthony commented Nov 16, 2024

Hi @5aaee9 - Are you still interested in adding Garble support to v3? I just tested this PR and noticed that the bindings don't work, because part of the path to the method has been obfuscated:
```Adding method: name=main.CInKAy8lI3x.Greet id=2914573282``
We could get around this by choosing to map methods by IDs only for Garble builds but it would take some work in the bindings processor.
Is this something you'd be interested in looking at?

To reproduce the bindings issue, just generate a project and build with garble. I added LogLevel: slog.LevelDebug, to my application options to see the debug logs.

@leaanthony leaanthony added the TODO The issue is ready to be developed label Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TODO The issue is ready to be developed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants