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

Add reflection awareness to transformLinkname #883

Merged
merged 6 commits into from
Nov 2, 2024

Conversation

NHAS
Copy link
Contributor

@NHAS NHAS commented Oct 27, 2024

Here's the fix for #882

Hopefully its not too naive as I dont have a super great understanding of the codebase!

@lu4p
Copy link
Member

lu4p commented Oct 28, 2024

@NHAS
Copy link
Contributor Author

NHAS commented Oct 28, 2024

Sure, it might take me a little bit as I dont fully understand how garble detects reflection on types

Copy link
Member

@lu4p lu4p left a comment

Choose a reason for hiding this comment

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

This change overall seems fine, just needs some small changes.

main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
@lu4p
Copy link
Member

lu4p commented Oct 28, 2024

Sure, it might take me a little bit as I dont fully understand how garble detects reflection on types

You just need to add the example you already provided in your issue. I don't expect you to learn how we do reflection detection.

Read https://github.com/burrowers/garble/blob/master/CONTRIBUTING.md as an introduction.

@NHAS
Copy link
Contributor Author

NHAS commented Oct 29, 2024

I am yet to add the test, as it would involve writing a package that is interacted with via reflection that disabled obfuscation. As I cant use crypto/x/ssh as tests cant import packages.

@lu4p
Copy link
Member

lu4p commented Oct 29, 2024

You can definitely import remote packages, but that is a bit more involved.

I think in this case it's easier to just declare a Method in a package and then linknaming it from another.

@NHAS
Copy link
Contributor Author

NHAS commented Oct 29, 2024

Ah sorry, I was a little unclear. I was meaning importing a remote package (in this case crypto/x/ssh).

In this case doesnt it have to be a new package that is also then interacted with via reflection so that obfuscation is turned off? Hence me needing to understand how a package is determined to be a target for reflection

@lu4p
Copy link
Member

lu4p commented Oct 30, 2024

You can use

var _ = reflect.TypeOf(t{})

To exclude type t from obfuscation, basically any type that is used in reflection somewhere is excluded.

@NHAS
Copy link
Contributor Author

NHAS commented Oct 31, 2024

Sweet thanks, I've added the test and made sure it fails without my changes, and passes with them :)

Copy link
Member

@lu4p lu4p left a comment

Choose a reason for hiding this comment

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

Just a few last comments

testdata/script/linkname.txtar Outdated Show resolved Hide resolved
hash.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
testdata/script/linkname.txtar Outdated Show resolved Hide resolved
@NHAS
Copy link
Contributor Author

NHAS commented Nov 1, 2024

Right I've made those changes that you asked for.

@lu4p lu4p merged commit 69d7b84 into burrowers:master Nov 2, 2024
7 checks passed
@NHAS
Copy link
Contributor Author

NHAS commented Nov 2, 2024

Just a small question on this now that its merged, what are the criteria for a release being made for this? I just have an open issue on my repo that regards this

@lu4p
Copy link
Member

lu4p commented Nov 2, 2024

You can use

go install mvdan.cc/garble@master

for now, maybe after #876 is merged.

@NHAS
Copy link
Contributor Author

NHAS commented Nov 2, 2024

Is the main branch considered stable? I just dont want my builds pointing to something that may break in the future

@lu4p
Copy link
Member

lu4p commented Nov 3, 2024

The code pushed to the master branch is tested extensively and doesn't really differ from the release versions. However we may deprecate old go versions on the master branch without notice.

You can also use @commit_hash to pin to a specific commit if you're more comfortable with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants