-
-
Notifications
You must be signed in to change notification settings - Fork 334
Add Sentry-compatible output flag and handling for reverse command #955
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: ZanderCodes <[email protected]>
|
I think if we want to support this reverse should detect automatically whether its a sentry stack trace. Also this needs to be added to the reverse.txtar test. @mvdan what's your opinion on this? |
Yes, it would make sense to recognize this automatically, but this would require almost the entire reverse function to be rewritten. |
|
Testscript is relatively straightforward it's basically just some commands at the top and then multiple files delimited by Also have a look at https://github.com/burrowers/garble/blob/master/CONTRIBUTING.md Basically you need to add a new block like this: Where the stdin is a file you want to reverse and stout a new one with the output you expect. Then just run For syntax highlighting use: https://marketplace.visualstudio.com/items?itemName=twpayne.vscode-testscript As for the entire reverse function having to be rewritten, can't you detect it somewhere at the beginning and then basically set some variable to trigger your current block. |
Signed-off-by: ZanderCodes <[email protected]>
|
@lu4p I created the testdata in the file "reverse-sentry.txtar" |
|
Great that you figured out how to use testscript! You'll still need to remove the I would probably use simple regex which matches the format of a sentry traceback line. https://regexr.com/ is helpful Also the test you wrote is currently not passing and you still need to test the json input. |
I thought if the command “go test -run=Script/reverse-sentry -u” worked and returned an OK everything would be fine. Ok, I have removed the Sentry flag and implement this directly in the reverse function |
|
-u tells it to automatically update the output You'll need to run it one more time without -u to verify your output is consistent. You can look at the failing CI it shows a diff of expected and actual output |
|
Adding this seems fine, but don't hide it behind a flag. If the number of replacements growing too large is a problem, we just need a better algorithm for them, but I think what we have now should scale well enough. |
If I have time in the next few days I will change the approach I implemented. |
|
That's fine. If you want to go that route, I'd consider regular expressions, which already support named groups to match with, and replace: https://pkg.go.dev/regexp/syntax |
Adding support for deobfuscate Sentry/Bugsink stack trace.
Example:
For Plaintext
in this
and for json:
{ "exception": [ { "value": "can't continue", "stacktrace": { "frames": [ { "function": "main", "module": "main", "filename": "ajB5WpM.go", "lineno": 1, "in_app": true }, { "function": "(*GcPJXBo0O).Msg", "module": "pNelqfz", "filename": "YVDM2UvBa1pK.go", "lineno": 1, "in_app": true }, { "function": "(*GcPJXBo0O).ia6J1v", "module": "pNelqfz", "filename": "PmRYfUF7fV.go", "lineno": 1, "in_app": true }, { "function": "(*GcPJXBo0O).jqLodorEA6", "module": "pNelqfz", "filename": "QR8skLy.go", "lineno": 1, "in_app": true }, { "function": "g6qBd3.WriteLevel", "module": "pNelqfz", "filename": "u9qkupM.go", "lineno": 1, "in_app": true }, { "function": "(*TkPbGafI).WriteLevel", "module": "AHvhwz", "filename": "vAaFg7om.go", "lineno": 1, "in_app": true }, { "function": "zZKJ7aezE", "module": "AHvhwz", "filename": "nQS6ZC5.go", "lineno": 1, "in_app": true }, { "function": "Sh0RufN", "module": "xojCOs6D", "filename": "HY7R3HYUYbp0.go", "lineno": 1, "in_app": true }, { "function": "zZKJ7aezE.func1", "module": "AHvhwz", "filename": "A8_tfqaEPrO.go", "lineno": 1, "in_app": true }, { "function": "NTSkDRlZS", "module": "NkEMIOCQ", "filename": "sAof1b2PSs.go", "lineno": 1, "in_app": true } ] } } ] }in this
{ "exception": [ { "value": "can't continue", "stacktrace": { "frames": [ { "function": "main", "module": "main", "filename": "app/cmd/app/main.go", "lineno": 56, "in_app": true }, { "function": "(*Event).Msg", "module": "github.com/rs/zerolog", "filename": "github.com/rs/zerolog/event.go", "lineno": 110, "in_app": true }, { "function": "(*Event).msg", "module": "github.com/rs/zerolog", "filename": "github.com/rs/zerolog/event.go", "lineno": 151, "in_app": true }, { "function": "(*Event).write", "module": "github.com/rs/zerolog", "filename": "github.com/rs/zerolog/event.go", "lineno": 80, "in_app": true }, { "function": "multiLevelWriter.WriteLevel", "module": "github.com/rs/zerolog", "filename": "github.com/rs/zerolog/writer.go", "lineno": 98, "in_app": true }, { "function": "(*Writer).WriteLevel", "module": "github.com/getsentry/sentry-go/zerolog", "filename": "github.com/getsentry/sentry-go/zerolog/sentryzerolog.go", "lineno": 213, "in_app": true }, { "function": "parseLogEvent", "module": "github.com/getsentry/sentry-go/zerolog", "filename": "github.com/getsentry/sentry-go/zerolog/sentryzerolog.go", "lineno": 263, "in_app": true }, { "function": "ObjectEach", "module": "github.com/buger/jsonparser", "filename": "github.com/buger/jsonparser/parser.go", "lineno": 1128, "in_app": true }, { "function": "parseLogEvent.func1", "module": "github.com/getsentry/sentry-go/zerolog", "filename": "github.com/getsentry/sentry-go/zerolog/sentryzerolog.go", "lineno": 271, "in_app": true }, { "function": "NewStacktrace", "module": "github.com/getsentry/sentry-go", "filename": "github.com/getsentry/sentry-go/stacktrace.go", "lineno": 29, "in_app": true } ] } } ] }