Skip to content

fix: improve detector unit test data for kraken, netsuite, viewneo#4831

Open
raajheshkannaa wants to merge 3 commits intotrufflesecurity:mainfrom
raajheshkannaa:fix/detector-unit-tests
Open

fix: improve detector unit test data for kraken, netsuite, viewneo#4831
raajheshkannaa wants to merge 3 commits intotrufflesecurity:mainfrom
raajheshkannaa:fix/detector-unit-tests

Conversation

@raajheshkannaa
Copy link
Copy Markdown

@raajheshkannaa raajheshkannaa commented Mar 24, 2026

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:

  • kraken: Replaced invalid base64 test strings (with = padding mid-string) with properly encoded keys matching real Kraken API format
  • netsuite: Used realistic sandbox account ID format, added documentation comments explaining TBA credential structure
  • viewneo: Replaced opaque blob with structured JWT-like token (header.payload.signature), fixed invalid pattern placement

Test plan

  • go test ./pkg/detectors/kraken/... passes
  • go test ./pkg/detectors/netsuite/... passes
  • go test ./pkg/detectors/viewneo/... passes
  • Test data now resembles real credential formats rather than regex artifacts

Note

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, and viewneo by 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 within PrefixRegex proximity, and a JWT-like header.payload.signature token), 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.

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)
@raajheshkannaa raajheshkannaa requested a review from a team March 24, 2026 00:28
@raajheshkannaa raajheshkannaa requested a review from a team as a code owner March 24, 2026 00:28
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 24, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

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.
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.

Fix broken & inaccurate detector unit tests

2 participants