|
| 1 | +# Nightfall Python SDK |
| 2 | + |
| 3 | +This is a python SDK for working with the Nightfall API. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +This module requires Python 3.6 or higher. |
| 8 | + |
| 9 | +``` |
| 10 | +pip install nightfall |
| 11 | +``` |
| 12 | + |
| 13 | +## Quickstart |
| 14 | + |
| 15 | +Make a new [API Token](https://app.nightfall.ai/api/) and [Detection Rule Set](https://app.nightfall.ai/detection-engine/detection-rules) in Nightfall and store the values as environment variables. |
| 16 | + |
| 17 | +``` |
| 18 | +from nightfall import Api |
| 19 | +
|
| 20 | +nightfall = Api( |
| 21 | + os.getenv('NIGHTFALL_TOKEN'), |
| 22 | + os.getenv('NIGHTFALL_CONDITION_SET') |
| 23 | + ) |
| 24 | +
|
| 25 | +response = nightfall.scan(['test string']) |
| 26 | +
|
| 27 | +findings = response.json() |
| 28 | +print(findings) |
| 29 | +``` |
| 30 | + |
| 31 | +## Contributing |
| 32 | + |
| 33 | +Please create an issue with a description of your problem, or open a pull request with the fix. |
| 34 | + |
| 35 | +## Development |
| 36 | + |
| 37 | +### Installing Development Dependencies |
| 38 | + |
| 39 | +If you want to hack on this project, you should set up your local development |
| 40 | +environment with the following commands: |
| 41 | + |
| 42 | +1. Fork and clone this repo and open a terminal with the root of this repository in your working directory. |
| 43 | +1. Create and activate a virtualenv `python3 -m venv venv && source venv/bin/activate` |
| 44 | +1. Install development dependencies with `pip install -r dev-requirements.txt` |
| 45 | +1. Install an editable version of this package `pip install -e .` |
| 46 | + |
| 47 | +### Run Unit Tests |
| 48 | + |
| 49 | +Unit tests can be found in the `tests/` directory. You can run them with `make test`. Be sure to have `NIGHTFALL_TOKEN` and `NIGHTFALL_CONDITION_SET` set as environment variables before running the tests. |
| 50 | + |
| 51 | +### View Code Coverage |
| 52 | + |
| 53 | +You can view the code coverage report by running `coverage html` and `python3 -m http.server --directory htmlcov` after running the unit tests. |
| 54 | + |
| 55 | +### SDK Documentation |
| 56 | + |
| 57 | +The SDK is documented using the Sphinx library. You can generatre the developer documentation using `make docs` and preview it on `localhost:8000` by running `python3 -m http.server --directory docs/_build/html`. |
| 58 | + |
| 59 | +### Creating a Release |
| 60 | + |
| 61 | +Releases are automatically published to PyPI using GitHub Actions. Creating a release in GitHub will trigger a new build that will publish the latest version of this library to [PyPI](https://pypi.org/project/nightfall/). |
| 62 | + |
| 63 | +The steps to do this are: |
| 64 | + |
| 65 | +1. Add what changed to the CHANGELOG file. |
| 66 | +2. Update the version in `setup.py` |
| 67 | +3. Commit changes and push to the main branch. |
| 68 | +4. Create a new release in the GitHub UI. |
| 69 | +5. Observe the release action succeed and see the latest version of this library on PyPI. |
| 70 | +## License |
| 71 | + |
| 72 | +MIT |
| 73 | + |
| 74 | + |
0 commit comments