-
Notifications
You must be signed in to change notification settings - Fork 2
/
text_scanner.go
52 lines (47 loc) · 1.22 KB
/
text_scanner.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"context"
"fmt"
"os"
"github.com/nightfallai/nightfall-go-sdk"
)
func scanText() (*nightfall.ScanTextResponse, error) {
nc, err := nightfall.NewClient()
if err != nil {
return nil, fmt.Errorf("Error initializing client: %w", err)
}
resp, err := nc.ScanText(context.Background(), &nightfall.ScanTextRequest{
Payload: []string{"4242 4242 4242 4242 is my ccn"},
Config: &nightfall.Config{
// A rule contains a set of detectors to scan with
DetectionRules: []nightfall.DetectionRule{{
// Define some detectors to use to scan your data
Detectors: []nightfall.Detector{{
MinNumFindings: 1,
MinConfidence: nightfall.ConfidencePossible,
DisplayName: "cc#",
DetectorType: nightfall.DetectorTypeNightfallDetector,
NightfallDetector: "CREDIT_CARD_NUMBER",
}},
LogicalOp: nightfall.LogicalOpAny,
},
},
},
})
if err != nil {
return nil, fmt.Errorf("Error scanning text: %w", err)
}
return resp, nil
}
func main() {
resp, err := scanText()
if err != nil {
fmt.Printf("Got error: %v", err)
os.Exit(-1)
}
for _, findings := range resp.Findings {
for _, finding := range findings {
fmt.Printf("Got finding %v", finding)
}
}
}