microsoft / genaiscript

Automatable GenAI Scripting
https://microsoft.github.io/genaiscript/
MIT License
2.02k stars 115 forks source link

Credscan #871

Closed pelikhan closed 1 week ago

pelikhan commented 1 week ago

- 🔒 **Enhanced Security**: Introduced a `hideSecrets` function to mask sensitive information such as API keys and tokens within message content. - 🛡️ **Secret Protection**: Applied `hideSecrets` to user, assistant, and system messages to prevent accidental leakage of secrets in output or logs. - 🔧 **Trace Safety**: Integrated `hideSecrets` in the `MarkdownTrace` class to secure content tracing by ensuring sensitive data doesn't appear in trace logs. - 📦 **New Module**: Added a `secrets.ts` file with predefined regular expressions to identify various secret patterns like GitHub tokens, API keys, and more. - 📜 **Log Verbosity**: Added verbose logging to indicate when and what kind of potential secret is being masked, enhancing monitoring and debugging efforts. > generated by [pr-describe](https://github.com/microsoft/genaiscript/actions/runs/11895798334)
github-actions[bot] commented 1 week ago

The changes made in the pull request focus on enhancing security by implementing a mechanism to hide secrets in user, assistant, and system messages, as well as in trace logs. This is done by introducing a new hideSecrets function, which identifies and obfuscates a wide range of sensitive patterns, such as API keys, tokens, and other credentials.

Key Changes:

Concerns:

Suggested Improvement:

Define patterns for "Private SSH Key" and "PEM Certificate" or remove them if not needed. Here's a possible placeholder fix:

+    "Private SSH Key": /-----BEGIN (?:RSA|DSA|EC|OPENSSH) PRIVATE KEY-----[\s\S]+?-----END (?:RSA|DSA|EC|OPENSSH) PRIVATE KEY-----/g,
+    "PEM Certificate": /-----BEGIN CERTIFICATE-----[\s\S]+?-----END CERTIFICATE-----/g,

Overall, the changes significantly improve the security aspect by ensuring sensitive information is not logged or exposed inadvertently.

LGTM 🚀

generated by pr-review