-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
added pattern test cases [WIP] #3539
base: main
Are you sure you want to change the base?
added pattern test cases [WIP] #3539
Conversation
var ( | ||
validPattern = ` | ||
apiflash_key: a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6 | ||
apiflash_url: abc123XYZ456def789ghijklm |
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.
According to the documentation, this parameter should be an actual URL, not a plain text string limited from 21 to 30 characters.
The current regex in use is: urlPat: \b([a-zA-Z0-9\S]{21,30})\b
.
complexPattern = ` | ||
func main() { | ||
url := "https://api.example.com/v1/resource" | ||
|
||
// Create a new request with the secret as a header | ||
req, err := http.NewRequest("POST", url, bytes.NewBuffer([]byte("{}"))) | ||
if err != nil { | ||
fmt.Println("Error creating request:", err) | ||
return | ||
} | ||
|
||
apactaSecret := "Bearer abcd1234-ef56-gh78-ij90-klmn1234opqr" | ||
req.Header.Set("Authorization", apactaSecret) |
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.
Feedback needed: How does this test example look? I aimed to create something that reflects a real-world scenario. If it looks good, I can use similar examples in the other test cases.
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"apimatic"}) + `\b([a-zA-Z0-9]{3,20}@[a-zA-Z0-9]{2,12}.[a-zA-Z0-9]{2,5})\b`) | ||
passPat = regexp.MustCompile(detectors.PrefixRegex([]string{"apimatic"}) + `\b([a-z0-9-\S]{8,32})\b`) | ||
apiKeyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"apimatic", "apikey"}) + `\b([a-zA-Z0-9_-]{64})\b`) |
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 somehow discovered that APIMatic is no longer using these for authentication and now utilizing an Auth Key
. Additionally, the API we were using earlier appears to no longer exist; it may have been available before, but the path seems to have changed in their documentation. I confirmed these updates through some local testing.
Documentation links are added in code comments, if you wanna take a look 🕵🏻
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.
3ecc0f4
to
b88073e
Compare
@@ -22,7 +22,7 @@ var ( | |||
client = common.SaneHttpClient() | |||
|
|||
// Make sure that your group is surrounded in boundary characters such as below to reduce false positives. | |||
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"apimetrics"}) + `\b([a-bA-Z0-9\S]{32})\b`) | |||
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"apimetrics"}) + `\b([a-zA-Z0-9]{32})\b`) |
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.
Improved APIMetrics
detector regex 🚀
f8d9a8d
to
14295d7
Compare
Description:
Added pattern test cases for Alphabet
A
detectorsSeparated integration tests
Checklist:
make test-community
)?make lint
this requires golangci-lint)?