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

fix: move invalid token to log field #1171

Merged
merged 3 commits into from
Jan 22, 2022
Merged

fix: move invalid token to log field #1171

merged 3 commits into from
Jan 22, 2022

Conversation

piksel
Copy link
Member

@piksel piksel commented Dec 20, 2021

Prevents potential log manipulation. Probably not a realistic concern, but fixing it is easier than dismissing the warnings.

@codecov
Copy link

codecov bot commented Dec 20, 2021

Codecov Report

Merging #1171 (0d07bfb) into main (d2f1185) will increase coverage by 0.80%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1171      +/-   ##
==========================================
+ Coverage   61.89%   62.70%   +0.80%     
==========================================
  Files          23       23              
  Lines        1475     1488      +13     
==========================================
+ Hits          913      933      +20     
+ Misses        476      471       -5     
+ Partials       86       84       -2     
Impacted Files Coverage Δ
pkg/api/api.go 39.28% <ø> (-4.05%) ⬇️
pkg/container/container.go 51.92% <0.00%> (ø)
pkg/notifications/email.go 90.69% <0.00%> (ø)
pkg/notifications/msteams.go 66.66% <0.00%> (ø)
pkg/notifications/shoutrrr.go 74.39% <0.00%> (+1.31%) ⬆️
internal/actions/update.go 69.10% <0.00%> (+5.54%) ⬆️
pkg/notifications/notifier.go 77.35% <0.00%> (+7.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d2f1185...0d07bfb. Read the comment docs.

@piksel
Copy link
Member Author

piksel commented Dec 20, 2021

😩

Welp, this PR actually does escape the input as a "safe" go-string, which should not trigger CWE-117 (all non-text characters are escaped, including newlines etc.).
So even if this fixes the potential issue, it still does not clear the warning (and even introduces another warning since we are outputting the HTTP headers).

@simskij
Copy link
Member

simskij commented Dec 27, 2021

Soo, are we closing this, or are you still looking to continue at some point? The easIER solution here would probably be to just escape it and log it as-is.

@piksel
Copy link
Member Author

piksel commented Dec 27, 2021

Well, it is escaped (using %q). Not sure how we could escape it in a way that doesn't trigger the security rule. I think it's marginally better in this version, since it's clearly distinguished from an actual log message, but we could also just remove it all together.

@simskij
Copy link
Member

simskij commented Dec 27, 2021

I think I prefer the second option

pkg/api/api.go Outdated Show resolved Hide resolved
@simskij simskij merged commit be33c64 into main Jan 22, 2022
@simskij simskij deleted the fix/api-token-log branch January 22, 2022 16:50
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