Skip to content

Commit

Permalink
Update secrets check to allow empty placehodlers (#172)
Browse files Browse the repository at this point in the history
* add hub files from Samples/azure-ai and update README

* test

* test

* test

* Add example for pre-commit secrets syntax

* Revert "add hub files from Samples/azure-ai and update README"

This reverts commit 2e822f8.

* Revert "test"

This reverts commit 555f8fe.
  • Loading branch information
diondrapeck authored Dec 26, 2024
1 parent d6e7428 commit f80d09d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .github/scripts/detect_azure_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
re.IGNORECASE,
),
re.compile(r'export\s+[A-Z_][A-Z0-9_]*\s*=\s*["\'][^"\']+["\']', re.IGNORECASE),
re.compile(r'os\.environ\["\s*[A-Za-z0-9_]*(API_KEY|ENDPOINT)[A-Za-z0-9_]*\s*"\]', re.IGNORECASE),
re.compile(
r'os\.environ\[\s*["\']\s*[A-Za-z0-9_]*(API_KEY|ENDPOINT|PROJECT_NAME|SUBSCRIPTION_ID|RESOURCE_GROUP)[A-Za-z0-9_]*\s*["\']\s*\]\s*=\s*["\'][^"\']+["\']',
re.IGNORECASE,
),
]


Expand Down
15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ pre-commit install
`pre-commit` will run automatically when you commit changes, but you can also manually run it using
`pre-commit run --all-files`.

Note:

pre-commit will check for any exposed secrets in your code. If you'd like to leave a placeholder for a secret, use this syntax to avoid being flagged by pre-commit:

```python
import os

os.environ["AZURE_SUBSCRIPTION_ID"] = ""
os.environ["AZURE_RESOURCE_GROUP"] = ""
os.environ["AZURE_PROJECT_NAME"] = ""
os.environ["AZURE_OPENAI_ENDPOINT"] = ""
...
```


#### Write your contribution

If you are writing/updating a sample, please follow this guidance on how the samples should be structured.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ If you'd like to implement it yourself, please refer to our [contributing guidel
[microsoft/chat-copilot]: https://github.com/microsoft/chat-copilot
[new issue page]: https://github.com/Azure-Samples/azureai-samples/issues/new/choose
[openai/openai-cookbook]: https://github.com/openai/openai-cookbook/tree/main/examples
[Azure-Samples/serverless-chat-langchainjs]: https://github.com/Azure-Samples/serverless-chat-langchainjs
[Azure-Samples/serverless-chat-langchainjs]: https://github.com/Azure-Samples/serverless-chat-langchainjs

0 comments on commit f80d09d

Please sign in to comment.