-
Notifications
You must be signed in to change notification settings - Fork 146
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
secret scanner #1068
Merged
Merged
secret scanner #1068
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3196c29
tiling info
pelikhan fa85260
basic secret scanning
pelikhan d60ca88
add basic key
pelikhan f4f771c
updated message
pelikhan 3d20d34
safety option
pelikhan b3bb85e
docs
pelikhan ccea08f
docs
pelikhan b8663f4
document removing secret scanners
pelikhan a4b78c6
add entry in readme
pelikhan ba1a13d
updated docs
pelikhan 6a8f463
add cli command
pelikhan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
77 changes: 77 additions & 0 deletions
77
docs/src/content/docs/reference/scripts/secret-scanning.mdx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
title: Secret Scanning | ||
sidebar: | ||
order: 10 | ||
--- | ||
|
||
One should not have secrets lying around in their codebase, but sometimes it happens. | ||
To help you avoid this, we have a secret scanning feature that will scan your codebase for secrets | ||
and warn you if any are found. | ||
|
||
:::note | ||
|
||
The secret scanning feature is by no means exhaustive and should not be relied upon as the sole | ||
method of securing your codebase. It is a best-effort feature that will help you avoid common mistakes. | ||
|
||
::: | ||
|
||
## Supported patterns | ||
|
||
By default set of secret patterns | ||
are defined at https://github.com/microsoft/genaiscript/tree/main/packages/core/src/config.json. | ||
|
||
:::cautio | ||
|
||
\is is not a complete list by design, and needs to be updated to match your needs. | ||
|
||
::: | ||
|
||
You can find examples of patterns at https://github.com/mazen160/secrets-patterns-db/. | ||
|
||
## Scanning messages | ||
|
||
By default, all messages sent to LLMs are scanned and redacted if they contain secrets. | ||
|
||
You can disable secret scanning alltogher by setting the `secretScanning` option to `false` in your script. | ||
|
||
```js | ||
script({ | ||
secretScanning: false, | ||
}) | ||
``` | ||
|
||
## Configuring patterns | ||
|
||
If you have a specific pattern that you want to scan for, you can configure it in your | ||
[configuration file](/genaiscript/reference/scripts/configuration-files). | ||
|
||
```json title="genaiscript.config.json" | ||
{ | ||
"secretPatterns": { | ||
..., | ||
"my secret pattern": "my-secret-pattern-regex" | ||
} | ||
} | ||
``` | ||
|
||
- do not use `^` or `$` in your regex pattern | ||
|
||
### Disabling patterns | ||
|
||
Set the pattern key to `null` or `false` to disable it. | ||
|
||
```json title="genaiscript.config.json" | ||
{ | ||
"secretPatterns": { | ||
"OpenAI API Key": null | ||
} | ||
} | ||
``` | ||
|
||
## CLI | ||
|
||
You can test your patterns against files using the CLI. | ||
|
||
```sh | ||
npx --yes genaiscript parse secrets * | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3463,7 +3463,8 @@ system({ | |
title: "Tools support", | ||
}) | ||
|
||
$`Use tools if possible. | ||
$`## Tools | ||
Use tools if possible. | ||
- **Do NOT invent function names**. | ||
- **Do NOT use function names starting with 'functions.'. | ||
- **Do NOT respond with multi_tool_use**.` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The introduction of a new heading without context can be confusing. Ensure that the new section provides clear information and is well-integrated with the existing content.
|
||
|
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"$schema": "../../../docs/public/schemas/config.json", | ||
"secretPatterns": { | ||
"OpenAI API Key": "sk-[A-Za-z0-9]{32,48}" | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Consider adding a brief introduction or context to the "Tiling" section to help readers understand its relevance and purpose within the document.