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

Update sqlserver redaction, deduplication, and URI redaction #1369

Merged
merged 2 commits into from
Jun 9, 2023

Conversation

dustin-decker
Copy link
Contributor

@dustin-decker dustin-decker commented May 30, 2023

SQLServer wasn't being properly deduplicated and URI wasn't being properly redacted in some cases

@dustin-decker dustin-decker requested review from a team May 30, 2023 16:44
pkg/detectors/detectors.go Outdated Show resolved Hide resolved
continue
}

detected := detectors.Result{
DetectorType: detectorspb.DetectorType_SQLServer,
Raw: []byte(params.Password),
Raw: []byte(paramsUnsafe.Password),
RawV2: []byte(paramsUnsafe.URL().String()),
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: Will this potentially lead to duplicate results similar to to the changes we made earlier with the other detectors. Since Raw and RawV2 are used as part of the lookup during deduplication we would create a new secret with potentially the same Raw value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly. I need to sync with @trufflesteeeve on this since the whole point of introducing RawV2 was to start properly deduping detectors that had an incorrect raw field.

Copy link
Collaborator

@trufflesteeeve trufflesteeeve May 30, 2023

Choose a reason for hiding this comment

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

It's been a while since that was added. I'll have to read the code to see what should be happening. We did see a secret duplication issue when RawV2 was added before, though.

Also I'm not 100% sure how this interacts with SecretsV2.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So I think I understand where the hashv2 duplication came from. We've always been adding the hashv2 to the secrets - https://github.com/trufflesecurity/thog/blob/46fe1c8d6d5b13737c603e20bafded703fc066c9/scanner/pkg/secrets/secret.go#L81

But if there was no rawv2, then that's just a hash of empty string. But it still gives it a hashv2 value. So when we look it up when we actually have a hash v2 value, it's different. I think we need to adjust our hashv2 lookup logic to include the default hash of empty string as well, and treat it as if there is no hashv2.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, let's adjust that before merging this or any more changes w/ rawv2

Copy link
Collaborator

Choose a reason for hiding this comment

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

I have the PR for the fix here, nearly done - https://github.com/trufflesecurity/thog/pull/1065

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm also noticing that with secretsv2 saving, changing the HashV2 will always create a new secret.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've fully updated but not yet tested the PR above to allow HashV2 to be fine to update. I'm going to try and finish that up early tomorrow.

@ahrav ahrav merged commit ca19472 into main Jun 9, 2023
@ahrav ahrav deleted the fix-sqlserver branch June 9, 2023 18:06
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