# SecureLog
SecureLog is a Python library designed to enhance the security of logging by preventing the leakage of sensitive information. It checks log messages for secrets and prints them securely, ensuring that sensitive data is not exposed in logs.
## Features
- **Secure Logging**: Automatically checks log messages for secrets and prints them securely.
- **Environment-Specific Configuration**: Allows disabling console logging based on the environment variable value.
- **Warning or Exit**: Can be configured to either issue a warning or exit the process when a secret is detected.
## Installation
To install SecureLog, use pip:
```
pip install secure-log==0.1.1
```
## Usage
### Basic Usage
To use SecureLog, simply import the `SecureLog` class and create an instance:
```python
from secure_log import SecureLog
from secure_log import SecureLog
print = SecureLog().secure_print
```
You can override the default `print` function with `secure_print` or use `secure_print ` directly for printing.
### Configuration
You can configure SecureLog by passing an `OptionsDict` to the constructor. The `OptionsDict` can include the following keys:
- `disableOn`: The environment variable value on which console logging should be disabled. This checks the value of `PYTHON_ENV`. Expected type: `str`.
- `warnOnly`: If `True`, only a warning is issued when a secret is detected in the log message. Otherwise, the process exits. Expected type: `bool`.
Example:
```python
options = {
"disableOn": "production",
"warnOnly": True
}
secure_log = SecureLog(options=options)
secure_log.secure_print("This is a secure log message.")
```
### Handling Potential Secrets Leak
If a secret is detected in a log message, SecureLog can either issue a warning or exit the process, depending on the `warnOnly` option.
```python
secure_log.secure_print("This message contains a secret: SECRET_KEY")
```
## Contributing
Contributions are welcome! Please read the [contributing guidelines](CONTRIBUTING.md) before getting started.
## License
SecureLog is released under the [MIT License](LICENSE).
## Contact
For any questions or concerns, please open an issue on GitHub.
Raw data
{
"_id": null,
"home_page": null,
"name": "secure-log",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "secure logging package",
"author": "Samuel Olusola",
"author_email": "sola@onboardbase.com",
"download_url": "https://files.pythonhosted.org/packages/8a/9d/c668cd35d40a802bd5e29d0c1f03ad148dafa83bb0044b556dd9214bab6f/secure_log-0.1.1.tar.gz",
"platform": null,
"description": "# SecureLog\n\nSecureLog is a Python library designed to enhance the security of logging by preventing the leakage of sensitive information. It checks log messages for secrets and prints them securely, ensuring that sensitive data is not exposed in logs.\n\n## Features\n\n- **Secure Logging**: Automatically checks log messages for secrets and prints them securely.\n- **Environment-Specific Configuration**: Allows disabling console logging based on the environment variable value.\n- **Warning or Exit**: Can be configured to either issue a warning or exit the process when a secret is detected.\n\n## Installation\n\nTo install SecureLog, use pip:\n\n```\npip install secure-log==0.1.1\n```\n\n## Usage\n\n### Basic Usage\n\nTo use SecureLog, simply import the `SecureLog` class and create an instance:\n\n```python\nfrom secure_log import SecureLog\n\nfrom secure_log import SecureLog\nprint = SecureLog().secure_print\n```\nYou can override the default `print` function with `secure_print` or use `secure_print ` directly for printing.\n\n### Configuration\n\nYou can configure SecureLog by passing an `OptionsDict` to the constructor. The `OptionsDict` can include the following keys:\n\n- `disableOn`: The environment variable value on which console logging should be disabled. This checks the value of `PYTHON_ENV`. Expected type: `str`.\n- `warnOnly`: If `True`, only a warning is issued when a secret is detected in the log message. Otherwise, the process exits. Expected type: `bool`.\n\nExample:\n\n```python\noptions = {\n \"disableOn\": \"production\",\n \"warnOnly\": True\n}\nsecure_log = SecureLog(options=options)\nsecure_log.secure_print(\"This is a secure log message.\")\n```\n\n### Handling Potential Secrets Leak\n\nIf a secret is detected in a log message, SecureLog can either issue a warning or exit the process, depending on the `warnOnly` option.\n\n```python\nsecure_log.secure_print(\"This message contains a secret: SECRET_KEY\")\n```\n\n## Contributing\n\nContributions are welcome! Please read the [contributing guidelines](CONTRIBUTING.md) before getting started.\n\n## License\n\nSecureLog is released under the [MIT License](LICENSE).\n\n## Contact\n\nFor any questions or concerns, please open an issue on GitHub.\n",
"bugtrack_url": null,
"license": null,
"summary": "A package for secure logging",
"version": "0.1.1",
"project_urls": {
"Source": "https://github.com/Onboardbase/secure-log-py"
},
"split_keywords": [
"secure",
"logging",
"package"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ea8b86c3f8c2d82a0c235deb1fc75f3fe326b8d7ad644ee70d46865eb3ae9cb5",
"md5": "10247fb8361344378a583b794e41a0a5",
"sha256": "327a0a906e70465c0eae86b8d2568c3aaf899e48d2f37fb93a5a5f0d6fe8338c"
},
"downloads": -1,
"filename": "secure_log-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "10247fb8361344378a583b794e41a0a5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4355,
"upload_time": "2024-03-20T14:57:48",
"upload_time_iso_8601": "2024-03-20T14:57:48.536927Z",
"url": "https://files.pythonhosted.org/packages/ea/8b/86c3f8c2d82a0c235deb1fc75f3fe326b8d7ad644ee70d46865eb3ae9cb5/secure_log-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8a9dc668cd35d40a802bd5e29d0c1f03ad148dafa83bb0044b556dd9214bab6f",
"md5": "3482cdef4ab7df05789860096b761c1c",
"sha256": "aafcc0c1fb1bb1d6f0202609a2b442d1d74e27b776849db86224863c8b2af106"
},
"downloads": -1,
"filename": "secure_log-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "3482cdef4ab7df05789860096b761c1c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3886,
"upload_time": "2024-03-20T14:57:50",
"upload_time_iso_8601": "2024-03-20T14:57:50.295558Z",
"url": "https://files.pythonhosted.org/packages/8a/9d/c668cd35d40a802bd5e29d0c1f03ad148dafa83bb0044b556dd9214bab6f/secure_log-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-20 14:57:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Onboardbase",
"github_project": "secure-log-py",
"github_not_found": true,
"lcname": "secure-log"
}