Skip to content

Commit 14ee308

Browse files
author
Dan Hertz
committed
update readme
1 parent 3b6e774 commit 14ee308

File tree

1 file changed

+103
-26
lines changed

1 file changed

+103
-26
lines changed

README.md

Lines changed: 103 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,125 @@
11
# Nightfall Python SDK
22

3-
This is a python SDK for working with the Nightfall API.
3+
**Embed Nightfall scanning and detection functionality into Java applications**
44

55
[![PyPI version](https://badge.fury.io/py/nightfall.svg)](https://badge.fury.io/py/nightfall)
66

7+
## Features
78

8-
## Installation
9+
This SDK provides Python functions for interacting with the Nightfall API. It allows you to add functionality to your
10+
applications to scan plain text and files in order to detect different categories of information. You can leverage any
11+
of the detectors in Nightfall's pre-built library, or you may programmatically define your own custom detectors.
912

10-
This module requires Python 3.7 or higher.
13+
Additionally, this library provides convenience features such as encapsulating the steps to chunk and upload files.
14+
15+
To obtain an API Key, login to the [Nightfall dashboard](https://app.nightfall.ai/) and click the section
16+
titled "Manage API Keys".
17+
18+
See our [developer documentation](https://docs.nightfall.ai/docs/entities-and-terms-to-know) for more details about
19+
integrating with the Nightfall API.
20+
21+
## Dependencies
22+
23+
The Nightfall Python SDK requires Python 3.7 or later.
24+
25+
For a full list of external dependencies please consult `setup.py`.
26+
27+
28+
## Installation
1129

1230
```
1331
pip install nightfall
1432
```
1533

16-
## Quickstart
34+
## Usage
1735

18-
Make a new [API Token](https://app.nightfall.ai/api/) in Nightfall and store the value as an environment variable.
1936

20-
```python
21-
import os
37+
### Scanning Plain Text
38+
39+
Nightfall provides pre-built detector types, covering data types ranging from PII to PHI to credentials. The following
40+
snippet shows an example of how to scan using pre-built detectors.
2241

42+
#### Sample Code
43+
44+
```python
2345
from nightfall import Confidence, DetectionRule, Detector, Nightfall
2446

25-
nightfall = Nightfall(os.getenv('NIGHTFALL_API_KEY'))
47+
# By default, the client reads the API key from the environment variable NIGHTFALL_API_KEY
48+
nightfall = Nightfall()
49+
50+
# A rule contains a set of detectors to scan with
51+
detection_rule = DetectionRule([
52+
Detector(min_confidence=Confidence.LIKELY, nightfall_detector="CREDIT_CARD_NUMBER"),
53+
Detector(min_confidence=Confidence.POSSIBLE, nightfall_detector="US_SOCIAL_SECURITY_NUMBER"),
54+
])
2655

2756
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")])])
57+
["hello world", "my SSN is 678-99-8212", "4242-4242-4242-4242"],
58+
[detection_rule]
59+
)
60+
3261
print(findings)
3362
```
63+
### Scanning Files
64+
65+
Scanning common file types like PDF's or office documents typically requires cumbersome text
66+
extraction methods like OCR.
67+
68+
Rather than implementing this functionality yourself, the Nightfall API allows you to upload the
69+
original files, and then we'll handle the heavy lifting.
70+
71+
The file upload process is implemented as a series of requests to upload the file in chunks. The library
72+
provides a single method that wraps the steps required to upload your file. Please refer to the
73+
[API Reference](https://docs.nightfall.ai/reference) for more details.
74+
75+
The file is uploaded synchronously, but as files can be arbitrarily large, the scan itself is conducted asynchronously.
76+
The results from the scan are delivered by webhook; for more information about setting up a webhook server, refer to
77+
[the docs](https://docs.nightfall.ai/docs/creating-a-webhook-server).
78+
79+
#### Sample Code
80+
81+
```python
82+
from nightfall import Confidence, DetectionRule, Detector, Nightfall
83+
84+
# By default, the client reads the API key from the environment variable NIGHTFALL_API_KEY
85+
nightfall = Nightfall()
86+
87+
# A rule contains a set of detectors to scan with
88+
detection_rule = DetectionRule([
89+
Detector(min_confidence=Confidence.LIKELY, nightfall_detector="CREDIT_CARD_NUMBER"),
90+
Detector(min_confidence=Confidence.POSSIBLE, nightfall_detector="US_SOCIAL_SECURITY_NUMBER"),
91+
])
92+
93+
94+
# Upload the file and start the scan.
95+
# These are conducted asynchronously, so provide a webhook route to an HTTPS server to send results to.
96+
id, message = nightfall.scan_file(
97+
"./super-secret-credit-cards.pdf",
98+
"https://my-service.com/nightfall/listener",
99+
detection_rules=[detection_rule]
100+
)
101+
print("started scan", id, message)
102+
```
34103

35-
For more information on the details of this library, please refer to
36-
the [API Documentation](https://docs.nightfall.ai/).
37104
## Contributing
38105

39-
Please create an issue with a description of your problem, or open a pull request with the fix.
106+
Contributions are welcome! Open a pull request to fix a bug, or open an issue to discuss a new feature
107+
or change. Please adhere to the linting criteria defined in `checkstyle.xml`, and be sure to add unit
108+
tests for any new functionality you add.
109+
110+
Refer to `CONTRIBUTING.md` for the full details.
111+
112+
## License
113+
114+
This code is licensed under the terms of the MIT License. See [here](https://opensource.org/licenses/MIT)
115+
for more information.
40116

41-
## Development
117+
Java is licensed by Oracle. See [here](https://www.oracle.com/java/technologies/javase/jdk-faqs.html)
118+
for more information.
119+
120+
Please create an issue with a description of your problem, or open a pull request with the fix.
121+
122+
## Development
42123

43124
### Installing Development Dependencies
44125

@@ -58,19 +139,15 @@ Unit and Integration tests can be found in the `tests/` directory. You can run t
58139

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

61-
### Creating a Release
142+
### Creating a Release
62143

63-
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/).
144+
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/).
64145

65-
The steps to do this are:
146+
The steps to do this are:
66147

67148
1. Add what changed to the CHANGELOG file
68149
2. Update the version in `setup.py`
69-
3. Commit changes and push to the main branch.
70-
4. Create a new release in the GitHub UI.
71-
5. Observe the release action succeed and see the latest version of this library on PyPI.
72-
## License
73-
74-
MIT
75-
150+
3. Commit changes and push to the main branch.
151+
4. Create a new release in the GitHub UI.
152+
5. Observe the release action succeed and see the latest version of this library on PyPI.
76153

0 commit comments

Comments
 (0)