Skip to content

Commit b7ccd15

Browse files
authored
Merge pull request #7 from nightfallai/v1
v1 SDK
2 parents bac1803 + 18ae246 commit b7ccd15

File tree

113 files changed

+669
-22928
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+669
-22928
lines changed

.github/workflows/build-test-deploy.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,17 @@ jobs:
1919
python -m pip install --upgrade pip
2020
pip install -r dev-requirements.txt
2121
pip install -e .
22-
- name: Test with unittest
22+
- name: Lint with flake8
23+
run: |
24+
# stop the build if there are Python syntax errors or undefined names
25+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
26+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
27+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
28+
- name: Test with pytest
2329
env:
24-
NIGHTFALL_CONDITION_SET: ${{ secrets.NIGHTFALL_CONDITION_SET }}
25-
NIGHTFALL_TOKEN: ${{ secrets.NIGHTFALL_TOKEN }}
30+
NIGHTFALL_API_KEY: ${{ secrets.NIGHTFALL_API_KEY }}
2631
run: |
27-
python -m unittest discover
32+
pytest -m "not filetest" --cov=nightfall --cov-report term-missing tests
2833
- name: Build a binary wheel and source tarball
2934
run: |
3035
python -m build --sdist --wheel --outdir dist/

.github/workflows/build-test.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version: [3.6, 3.7, 3.8, 3.9]
10+
python-version: [3.7, 3.8, 3.9, "3.10"]
1111

1212
steps:
1313
- uses: actions/checkout@v2
@@ -26,9 +26,8 @@ jobs:
2626
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
2727
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
2828
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
29-
- name: Test with unittest
29+
- name: Test with pytest
3030
env:
31-
NIGHTFALL_CONDITION_SET: ${{ secrets.NIGHTFALL_CONDITION_SET }}
32-
NIGHTFALL_TOKEN: ${{ secrets.NIGHTFALL_TOKEN }}
31+
NIGHTFALL_API_KEY: ${{ secrets.NIGHTFALL_API_KEY }}
3332
run: |
34-
python -m unittest discover
33+
pytest -m "not filetest" --cov=nightfall --cov-report term-missing tests

Makefile

Lines changed: 0 additions & 30 deletions
This file was deleted.

README.md

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,29 @@ This is a python SDK for working with the Nightfall API.
77

88
## Installation
99

10-
This module requires Python 3.6 or higher.
10+
This module requires Python 3.7 or higher.
1111

1212
```
1313
pip install nightfall
1414
```
1515

1616
## Quickstart
1717

18-
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.
18+
Make a new [API Token](https://app.nightfall.ai/api/) in Nightfall and store the value as an environment variable.
1919

20-
```
21-
from nightfall import Nightfall
20+
```python
21+
import os
2222

23-
nightfall = Nightfall(
24-
os.getenv('NIGHTFALL_TOKEN'),
25-
os.getenv('NIGHTFALL_CONDITION_SET')
26-
)
23+
from nightfall import Confidence, DetectionRule, Detector, Nightfall
2724

28-
response = nightfall.scan({'id': 'test string'})
25+
nightfall = Nightfall(os.getenv('NIGHTFALL_API_KEY'))
2926

30-
print(response)
27+
findings, _ = nightfall.scan_text(
28+
["4916-6734-7572-5015 is my credit card number"],
29+
[DetectionRule(
30+
[Detector(min_confidence=Confidence.LIKELY,
31+
nightfall_detector="CREDIT_CARD_NUMBER")])])
32+
print(findings)
3133
```
3234

3335
For more information on the details of this library, please refer to
@@ -50,25 +52,20 @@ environment with the following commands:
5052

5153
### Run Unit Tests
5254

53-
Unit and Integration 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.
55+
Unit and Integration tests can be found in the `tests/` directory. You can run them with `pytest`. Be sure to have `NIGHTFALL_API_KEY` set as an environment variable before running the tests.
5456

5557
### View Code Coverage
5658

5759
You can view the code coverage report by running `coverage html` and `python3 -m http.server --directory htmlcov` after running the unit tests.
5860

59-
### SDK Documentation
60-
61-
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 `make serve-docs`.
62-
6361
### Creating a Release
6462

6563
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/).
6664

6765
The steps to do this are:
6866

6967
1. Add what changed to the CHANGELOG file
70-
1. Update the version in `setup.py`
71-
1. Generate documentation with `make docs` to make sure it's up to date
68+
2. Update the version in `setup.py`
7269
3. Commit changes and push to the main branch.
7370
4. Create a new release in the GitHub UI.
7471
5. Observe the release action succeed and see the latest version of this library on PyPI.

dev-requirements.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ sphinx-autobuild
99
sphinx_rtd_theme
1010
build
1111
flake8
12-
autopep8
12+
autopep8
13+
pytest
14+
pytest-cov
15+
requests

docs/.buildinfo

Lines changed: 0 additions & 4 deletions
This file was deleted.

docs/.nojekyll

Whitespace-only changes.

docs/_sources/api.rst.txt

Lines changed: 0 additions & 15 deletions
This file was deleted.

docs/_sources/changelog.rst.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/_sources/index.rst.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)