@@ -42,25 +42,25 @@ snippet shows an example of how to scan using pre-built detectors.
4242#### Sample Code
4343
4444``` python
45- from nightfall import Confidence, DetectionRule, Detector, Nightfall
45+ >> > from nightfall import Confidence, DetectionRule, Detector, Nightfall
4646
47- # By default, the client reads the API key from the environment variable NIGHTFALL_API_KEY
48- nightfall = Nightfall()
47+ >> > # By default, the client reads the API key from the environment variable NIGHTFALL_API_KEY
48+ >> > nightfall = Nightfall()
4949
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- ])
50+ >> > # A rule contains a set of detectors to scan with
51+ >> > cc = Detector(min_confidence = Confidence.LIKELY , nightfall_detector = " CREDIT_CARD_NUMBER" )
52+ >> > ssn = Detector(min_confidence = Confidence.POSSIBLE , nightfall_detector = " US_SOCIAL_SECURITY_NUMBER" )
53+ >> > detection_rule = DetectionRule([cc, ssn])
5554
56- findings, _ = nightfall.scan_text(
57- [ " hello world " , " my SSN is 678-99-8212 " , " 4242-4242-4242-4242 " ],
58- detection_rules = [detection_rule]
59- )
55+ >> > findings, _ = nightfall.scan_text( [ " hello world " , " my SSN is 678-99-8212 " , " 4242-4242-4242-4242 " ], detection_rules = [detection_rule])
56+
57+ >> > print (findings)
58+ [[], [Finding( finding = ' 678-99-8212 ' , redacted_finding = ... )]]
6059
61- print (findings)
6260```
6361
62+
63+
6464### Scanning Files
6565
6666Scanning common file types like PDF's or office documents typically requires cumbersome text
@@ -80,26 +80,24 @@ The results from the scan are delivered by webhook; for more information about s
8080#### Sample Code
8181
8282``` python
83- from nightfall import Confidence, DetectionRule, Detector, Nightfall
84-
85- # By default, the client reads the API key from the environment variable NIGHTFALL_API_KEY
86- nightfall = Nightfall()
87-
88- # A rule contains a set of detectors to scan with
89- detection_rule = DetectionRule([
90- Detector(min_confidence = Confidence.LIKELY , nightfall_detector = " CREDIT_CARD_NUMBER" ),
91- Detector(min_confidence = Confidence.POSSIBLE , nightfall_detector = " US_SOCIAL_SECURITY_NUMBER" ),
92- ])
93-
94-
95- # Upload the file and start the scan.
96- # These are conducted asynchronously, so provide a webhook route to an HTTPS server to send results to.
97- id , message = nightfall.scan_file(
98- " ./super-secret-credit-cards.pdf" ,
99- " https://my-service.com/nightfall/listener" ,
100- detection_rules = [detection_rule]
101- )
102- print (" started scan" , id , message)
83+ >> > from nightfall import Confidence, DetectionRule, Detector, Nightfall
84+ >> > import os
85+
86+ >> > # By default, the client reads the API key from the environment variable NIGHTFALL_API_KEY
87+ >> > nightfall = Nightfall()
88+
89+ >> > # A rule contains a set of detectors to scan with
90+ >> > cc = Detector(min_confidence = Confidence.LIKELY , nightfall_detector = " CREDIT_CARD_NUMBER" )
91+ >> > ssn = Detector(min_confidence = Confidence.POSSIBLE , nightfall_detector = " US_SOCIAL_SECURITY_NUMBER" )
92+ >> > detection_rule = DetectionRule([cc, ssn])
93+
94+
95+ >> > # Upload the file and start the scan.
96+ >> > # These are conducted asynchronously, so provide a webhook route to an HTTPS server to send results to.
97+ >> > id , message = nightfall.scan_file( " ./README.md" , os.environ[" WEBHOOK_ENDPOINT" ], detection_rules = [detection_rule])
98+ >> > print (" started scan" , id , message)
99+ started scan... scan initiated
100+
103101```
104102
105103## Contributing
0 commit comments