fix: improve detector unit test data for kraken, netsuite, viewneo#4831
Open
raajheshkannaa wants to merge 3 commits intotrufflesecurity:mainfrom
Open
fix: improve detector unit test data for kraken, netsuite, viewneo#4831raajheshkannaa wants to merge 3 commits intotrufflesecurity:mainfrom
raajheshkannaa wants to merge 3 commits intotrufflesecurity:mainfrom
Conversation
Replace reverse-engineered, nonsensical test data with realistic credential formats that actually validate detector accuracy. - kraken: Use valid base64-encoded API key and private key instead of strings with = padding in the middle (invalid base64) - netsuite: Add comments explaining TBA credential format, use realistic account ID (TSTDRV sandbox prefix), reorganize test vars for clarity - viewneo: Replace opaque blob with structured JWT-like token (header.payload.signature), fix invalid pattern to actually break the regex match instead of just changing position 0 Closes trufflesecurity#3817 (partial)
Two test inputs hardcoded the "viewneo" string literal instead of using the package-level keyword variable, making it appear unused. Refactored both inputs to use fmt.Sprintf with keyword, consistent with kraken and netsuite test files in this PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes #3817 (partial)
Summary
Addresses three detectors explicitly cited in the issue where test data was reverse-engineered from regex patterns rather than matching real credential formats:
=padding mid-string) with properly encoded keys matching real Kraken API formatTest plan
go test ./pkg/detectors/kraken/...passesgo test ./pkg/detectors/netsuite/...passesgo test ./pkg/detectors/viewneo/...passesNote
Low Risk
Changes are confined to unit test fixtures and inputs, reducing risk to production behavior; main risk is minor test brittleness if regex expectations differ from real-world formats.
Overview
Improves detector unit tests for
kraken,netsuite, andviewneoby replacing regex-derived sample secrets with realistic-looking credential strings and adding clarifying comments about expected formats.Test inputs were adjusted to better reflect how secrets appear in configs (e.g., labeled
api_key/api_secret, NetSuite TBA fields kept withinPrefixRegexproximity, and a JWT-likeheader.payload.signaturetoken), and invalid cases now use disallowed characters to assert negative matching.Reviewed by Cursor Bugbot for commit da0b248. Bugbot is set up for automated code reviews on this repo. Configure here.