Skip to content

Conversation

@levlaz
Copy link
Contributor

@levlaz levlaz commented Jul 17, 2021

This commit is an improvement on the previous iteration where instead of
handling a list of dicts, we now handle a single dict with mulitple entries.
This simplifies the library code and makes the interface much more usable.

A simple test of this shows it working as expected.

Input

from nightfall import Nightfall
import pprint 

nightfall = Nightfall('API_KEY', 'CONDITION_SET')


resp = nightfall.scan(
    {
        "id1": "This is my API Key:2e519c0e-e9e2-454c-92ea-bbd07f96d558 and email address is test@testing.org", 
        "id2": "This is safe",
        "id3": "This is also safe",
        "id4": "This has an email bill@email.com",
        "id5": "This one is safe though."
    }
)

pprint.pprint(resp)

Output

{'id1': [{'confidence': 'VERY_LIKELY',
          'detectorName': 'Email address',
          'fragment': 'test@testing.org',
          'location': {'byteRange': {'end': 93, 'start': 77},
                       'unicodeRange': {'end': 93, 'start': 77}}},
         {'confidence': 'VERY_LIKELY',
          'detectorName': 'API key',
          'fragment': '2e519c0e-e9e2-454c-92ea-bbd07f96d558',
          'location': {'byteRange': {'end': 55, 'start': 19},
                       'unicodeRange': {'end': 55, 'start': 19}}}],
 'id2': None,
 'id3': None,
 'id4': [{'confidence': 'VERY_LIKELY',
          'detectorName': 'Email address',
          'fragment': 'bill@email.com',
          'location': {'byteRange': {'end': 32, 'start': 18},
                       'unicodeRange': {'end': 32, 'start': 18}}}],
 'id5': None}

levlaz added 3 commits July 16, 2021 18:38
Refactor scan and chunking interface to handle dict with multiple items
instead of list of dicts.
@levlaz levlaz merged commit 7bbf9ac into main Jul 26, 2021
@levlaz levlaz deleted the patch-dict branch July 26, 2021 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants