-
Notifications
You must be signed in to change notification settings - Fork 320
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: properly escape table name when querying for failed events #2663
Conversation
d1efe2d
to
eaceb65
Compare
eaceb65
to
c0c4c43
Compare
Codecov ReportBase: 43.73% // Head: 45.34% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #2663 +/- ##
==========================================
+ Coverage 43.73% 45.34% +1.60%
==========================================
Files 191 287 +96
Lines 40483 47780 +7297
==========================================
+ Hits 17707 21667 +3960
- Misses 21671 24745 +3074
- Partials 1105 1368 +263
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could use a function for escaping these 🤔 Optional of course.
@@ -55,7 +56,7 @@ func (*FailedEventsManagerT) SaveFailedRecordIDs(taskRunIDFailedEventsMap map[st | |||
} | |||
|
|||
for taskRunID, failedEvents := range taskRunIDFailedEventsMap { | |||
table := fmt.Sprintf(`%s_%s`, failedKeysTablePrefix, taskRunID) | |||
table := `"` + strings.ReplaceAll(fmt.Sprintf(`%s_%s`, failedKeysTablePrefix, taskRunID), `"`, `""`) + `"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is probably a temporary measure. It would make more sense to perform this in failedEventsHandler()
where both SaveFailedRecordIDs()
and FetchFailedRecordIDs()
are called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chrikar The goal of this pr is to evade a security risk with respect to /v1/failed-events endpoint. SaveFailedRecordIDs
function is not exposed outside. So, no risk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point @chandumlg is that this conversion should happen at the handler endpoint, not the internal function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the HTTP handler should not know how/where failed events are stored, let alone that jobRunId needs to be escaped as if it was a postgresql identifier in the first place :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! Apologies. I misread the changes in this pr. I thought the escaping is done on exposed functions FetchFailedRecordIDs
& DropFailedRecordIDs
and felt it is not necessary to modify SaveFailedRecordIDs
.
Description
Using double quotes and escaping the table name when querying for failed events, until we drop support for the old endpoint.
Reference
Security