From b6f658d59b9b910c14a4a9fe3a28d0b5bd8ce38d Mon Sep 17 00:00:00 2001 From: Chris Campo Date: Fri, 29 Mar 2024 13:24:07 -0400 Subject: [PATCH] Fix OPA tests --- .github/workflows/docker.yaml | 16 +++ .github/workflows/opa.yaml | 22 +++++ classification/rego/address_test.rego | 62 ++++++------ classification/rego/age_test.rego | 38 ++++---- classification/rego/ccn_test.rego | 26 ++--- classification/rego/cvv_test.rego | 30 +++--- classification/rego/dob_test.rego | 102 ++++++++++---------- classification/rego/email_test.rego | 14 +-- classification/rego/first_name_test.rego | 50 +++++----- classification/rego/full_name_test.rego | 26 ++--- classification/rego/ip_address_test.rego | 26 ++--- classification/rego/last_name_test.rego | 50 +++++----- classification/rego/passport_test.rego | 54 ++++++----- classification/rego/phone_test.rego | 14 +-- classification/rego/ssn_test.rego | 74 +++++++------- discovery/repository/snowflake/snowflake.go | 2 +- 16 files changed, 335 insertions(+), 271 deletions(-) create mode 100644 .github/workflows/docker.yaml create mode 100644 .github/workflows/opa.yaml diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000..9269204 --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,16 @@ +name: Build CLI Docker Image + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Build Docker image + run: docker build . --file Dockerfile diff --git a/.github/workflows/opa.yaml b/.github/workflows/opa.yaml new file mode 100644 index 0000000..778f7b6 --- /dev/null +++ b/.github/workflows/opa.yaml @@ -0,0 +1,22 @@ +name: Run OPA Tests + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + + - name: Setup OPA + uses: open-policy-agent/setup-opa@v2 + with: + version: latest + + - name: Run OPA Tests + run: opa test classification/rego/*.rego -v diff --git a/classification/rego/address_test.rego b/classification/rego/address_test.rego index e97150e..98b1b67 100644 --- a/classification/rego/address_test.rego +++ b/classification/rego/address_test.rego @@ -1,61 +1,63 @@ package classifier_address -test_no_label { - output.column == "UNLABELED" with input as {"column":"invalid"} +import rego.v1 + +test_no_label if { + output.column == false with input as {"column":"invalid"} } -test_column_name_state { - output.state == "ADDRESS" with input as {"state":"AZ"} +test_column_name_state if { + output.state == true with input as {"state":"AZ"} } -test_insensitive_column_name_state { - output.STATE == "ADDRESS" with input as {"STATE":"AZ"} +test_insensitive_column_name_state if { + output.STATE == true with input as {"STATE":"AZ"} } -test_column_name_address { - output.address == "ADDRESS" with input as {"address":"123 some street"} +test_column_name_address if { + output.address == true with input as {"address":"123 some street"} } -test_insensitive_column_name_address { - output.ADDRESS == "ADDRESS" with input as {"ADDRESS":"123 some street"} +test_insensitive_column_name_address if { + output.ADDRESS == true with input as {"ADDRESS":"123 some street"} } -test_column_name_contains_address { - output.some_address_here == "ADDRESS" with input as {"some_address_here":"123 some street"} +test_column_name_contains_address if { + output.some_address_here == true with input as {"some_address_here":"123 some street"} } -test_insensitive_column_name_contains_address { - output.some_ADDRESS_Here == "ADDRESS" with input as {"some_ADDRESS_Here":"123 some street"} +test_insensitive_column_name_contains_address if { + output.some_ADDRESS_Here == true with input as {"some_ADDRESS_Here":"123 some street"} } -test_column_name_street { - output.street == "ADDRESS" with input as {"street":"123 some street"} +test_column_name_street if { + output.street == true with input as {"street":"123 some street"} } -test_insensitive_column_name_street { - output.STREET == "ADDRESS" with input as {"STREET":"123 some street"} +test_insensitive_column_name_street if { + output.STREET == true with input as {"STREET":"123 some street"} } -test_column_name_starts_with_street { - output.street_name == "ADDRESS" with input as {"street_name":"123 some street"} +test_column_name_starts_with_street if { + output.street_name == true with input as {"street_name":"123 some street"} } -test_insensitive_column_name_starts_with_street { - output.STREET_Name == "ADDRESS" with input as {"STREET_Name":"123 some street"} +test_insensitive_column_name_starts_with_street if { + output.STREET_Name == true with input as {"STREET_Name":"123 some street"} } -test_column_name_zip { - output.zip == "ADDRESS" with input as {"zip":"11111"} +test_column_name_zip if { + output.zip == true with input as {"zip":"11111"} } -test_insensitive_column_name_zip { - output.ZIP == "ADDRESS" with input as {"ZIP":"11111"} +test_insensitive_column_name_zip if { + output.ZIP == true with input as {"ZIP":"11111"} } -test_column_name_zipcode { - output.zipcode == "ADDRESS" with input as {"zipcode":"11111"} +test_column_name_zipcode if { + output.zipcode == true with input as {"zipcode":"11111"} } -test_insensitive_column_name_zipcode { - output.ZIPCODE == "ADDRESS" with input as {"ZIPCODE":"11111"} +test_insensitive_column_name_zipcode if { + output.ZIPCODE == true with input as {"ZIPCODE":"11111"} } diff --git a/classification/rego/age_test.rego b/classification/rego/age_test.rego index edc3ef5..3f6810a 100644 --- a/classification/rego/age_test.rego +++ b/classification/rego/age_test.rego @@ -1,37 +1,39 @@ package classifier_age -test_no_label { - output.column == "UNLABELED" with input as {"column":"invalid"} +import rego.v1 + +test_no_label if { + output.column == false with input as {"column":"invalid"} } -test_column_name_age_invalid_age { - output.age == "UNLABELED" with input as {"age":"120"} +test_column_name_age_invalid_age if { + output.age == false with input as {"age":"120"} } -test_insensitive_column_name_age_invalid { - output.AGE == "UNLABELED" with input as {"AGE":"120"} +test_insensitive_column_name_age_invalid if { + output.AGE == false with input as {"AGE":"120"} } -test_column_name_age_single_digit { - output.age == "AGE" with input as {"age":"1"} +test_column_name_age_single_digit if { + output.age == true with input as {"age":"1"} } -test_insensitive_column_name_age_single_digit { - output.AGE == "AGE" with input as {"AGE":"1"} +test_insensitive_column_name_age_single_digit if { + output.AGE == true with input as {"AGE":"1"} } -test_column_name_age_double_digit { - output.age == "AGE" with input as {"age":"10"} +test_column_name_age_double_digit if { + output.age == true with input as {"age":"10"} } -test_insensitive_column_name_age_double_digit { - output.AGE == "AGE" with input as {"AGE":"10"} +test_insensitive_column_name_age_double_digit if { + output.AGE == true with input as {"AGE":"10"} } -test_column_name_age_triple_digit { - output.age == "AGE" with input as {"age":"100"} +test_column_name_age_triple_digit if { + output.age == true with input as {"age":"100"} } -test_insensitive_column_name_age_triple_digit { - output.AGE == "AGE" with input as {"AGE":"100"} +test_insensitive_column_name_age_triple_digit if { + output.AGE == true with input as {"AGE":"100"} } diff --git a/classification/rego/ccn_test.rego b/classification/rego/ccn_test.rego index 31d2e40..b41dfb9 100644 --- a/classification/rego/ccn_test.rego +++ b/classification/rego/ccn_test.rego @@ -1,26 +1,28 @@ package classifier_ccn -test_no_label { - output.column == "UNLABELED" with input as {"column":"invalid"} +import rego.v1 + +test_no_label if { + output.column == false with input as {"column":"invalid"} } -test_valid_amex_ccn { - output.message == "CCN" with input as {"message":"370136066365291"} +test_valid_amex_ccn if { + output.message == true with input as {"message":"370136066365291"} } -test_valid_visa_ccn { - output.message == "CCN" with input as {"message":"4613688275707134"} +test_valid_visa_ccn if { + output.message == true with input as {"message":"4613688275707134"} } -test_valid_mastercard_ccn { - output.message == "CCN" with input as {"message":"5423909386888564"} +test_valid_mastercard_ccn if { + output.message == true with input as {"message":"5423909386888564"} } # TODO : Fix pattern to match -test_valid_mastercard_ccn { - output.message == "CCN" with input as {"message":"2701306282695666"} +test_valid_mastercard_ccn if { + output.message == true with input as {"message":"2701306282695666"} } -test_valid_discover_ccn { - output.message == "CCN" with input as {"message":"6536673682309236"} +test_valid_discover_ccn if { + output.message == true with input as {"message":"6536673682309236"} } diff --git a/classification/rego/cvv_test.rego b/classification/rego/cvv_test.rego index 233ec72..a947863 100644 --- a/classification/rego/cvv_test.rego +++ b/classification/rego/cvv_test.rego @@ -1,29 +1,31 @@ package classifier_cvv -test_cvv_key { - output.CVV == "CVV" with input as {"CVV":"test"} +import rego.v1 + +test_cvv_key if { + output.CVV == true with input as {"CVV":"test"} } -test_cvv_key { - output.cvv == "CVV" with input as {"cvv":"test"} +test_cvv_key if { + output.cvv == true with input as {"cvv":"test"} } -test_cvv_key { - output.CvV == "CVV" with input as {"CvV":"test"} +test_cvv_key if { + output.CvV == true with input as {"CvV":"test"} } -test_cvv_pattern { - output.message == "CVV" with input as {"message":"451"} +test_cvv_pattern if { + output.message == true with input as {"message":"451"} } -test_cvv_pattern { - output.message == "CVV" with input as {"message":"5061"} +test_cvv_pattern if { + output.message == true with input as {"message":"5061"} } -test_cvv_pattern { - output.message == "CVV" with input as {"message":"123"} +test_cvv_pattern if { + output.message == true with input as {"message":"123"} } -test_cvv_pattern { - output.message == "UNLABELED" with input as {"message":"12345"} +test_cvv_pattern if { + output.message == false with input as {"message":"12345"} } diff --git a/classification/rego/dob_test.rego b/classification/rego/dob_test.rego index bd25728..dfaab5a 100644 --- a/classification/rego/dob_test.rego +++ b/classification/rego/dob_test.rego @@ -1,110 +1,112 @@ package classifier_dob -test_dob_key { - output.dob == "DOB" with input as {"dob":"test"} +import rego.v1 + +test_dob_key if { + output.dob == true with input as {"dob":"test"} } -test_dob_key { - output.DOB == "DOB" with input as {"DOB":"test"} +test_dob_key if { + output.DOB == true with input as {"DOB":"test"} } -test_dob_key { - output.DoB == "DOB" with input as {"DoB":"test"} +test_dob_key if { + output.DoB == true with input as {"DoB":"test"} } -test_dob_key { - output.birthdate == "DOB" with input as {"birthdate":"test"} +test_dob_key if { + output.birthdate == true with input as {"birthdate":"test"} } -test_dob_key { - output.BirthDate == "DOB" with input as {"BirthDate":"test"} +test_dob_key if { + output.BirthDate == true with input as {"BirthDate":"test"} } -test_dob_key { - output.dateofbirth == "DOB" with input as {"dateofbirth":"test"} +test_dob_key if { + output.dateofbirth == true with input as {"dateofbirth":"test"} } -test_dob_key { - output.DateOfBirth == "DOB" with input as {"DateOfBirth":"test"} +test_dob_key if { + output.DateOfBirth == true with input as {"DateOfBirth":"test"} } -test_dob_key { - output.birthdate == "DOB" with input as {"birthdate":"test"} +test_dob_key if { + output.birthdate == true with input as {"birthdate":"test"} } -test_dob_key { - output.birth_date == "DOB" with input as {"birth_date":"test"} +test_dob_key if { + output.birth_date == true with input as {"birth_date":"test"} } # mm/dd/yyyy -test_dob_pattern { - output.message == "DOB" with input as {"message":"01/01/1900"} +test_dob_pattern if { + output.message == true with input as {"message":"01/01/1900"} } -test_dob_pattern { - output.message == "DOB" with input as {"message":"1-1-1900"} +test_dob_pattern if { + output.message == true with input as {"message":"1-1-1900"} } -test_dob_pattern { - output.message == "DOB" with input as {"message":"10.01.1971"} +test_dob_pattern if { + output.message == true with input as {"message":"10.01.1971"} } -test_dob_pattern { - output.message == "DOB" with input as {"message":"11/30/2023"} +test_dob_pattern if { + output.message == true with input as {"message":"11/30/2023"} } # dd/mm/yyyy -test_dob_pattern { - output.message == "DOB" with input as {"message":"01/01/1900"} +test_dob_pattern if { + output.message == true with input as {"message":"01/01/1900"} } -test_dob_pattern { - output.message == "DOB" with input as {"message":"1/1/1900"} +test_dob_pattern if { + output.message == true with input as {"message":"1/1/1900"} } -test_dob_pattern { - output.message == "DOB" with input as {"message":"10/01/1971"} +test_dob_pattern if { + output.message == true with input as {"message":"10/01/1971"} } -test_dob_pattern { - output.message == "DOB" with input as {"message":"30/11/2023"} +test_dob_pattern if { + output.message == true with input as {"message":"30/11/2023"} } # yyyy/mm/dd -test_dob_pattern { - output.message == "DOB" with input as {"message":"1900/01/10"} +test_dob_pattern if { + output.message == true with input as {"message":"1900/01/10"} } -test_dob_pattern { - output.message == "DOB" with input as {"message":"1900/1/1"} +test_dob_pattern if { + output.message == true with input as {"message":"1900/1/1"} } -test_dob_pattern { - output.message == "DOB" with input as {"message":"1971/10/01"} +test_dob_pattern if { + output.message == true with input as {"message":"1971/10/01"} } -test_dob_pattern { - output.message == "DOB" with input as {"message":"2023/12/31"} +test_dob_pattern if { + output.message == true with input as {"message":"2023/12/31"} } # yyyy-mm-dd -test_dob_pattern { - output.message == "DOB" with input as {"message":"1900-01-10"} +test_dob_pattern if { + output.message == true with input as {"message":"1900-01-10"} } -test_dob_pattern { - output.message == "DOB" with input as {"message":"1900-1-1"} +test_dob_pattern if { + output.message == true with input as {"message":"1900-1-1"} } -test_dob_pattern { - output.message == "DOB" with input as {"message":"1971-10-01"} +test_dob_pattern if { + output.message == true with input as {"message":"1971-10-01"} } -test_dob_pattern { - output.message == "DOB" with input as {"message":"2023-12-31"} +test_dob_pattern if { + output.message == true with input as {"message":"2023-12-31"} } diff --git a/classification/rego/email_test.rego b/classification/rego/email_test.rego index 3a5b007..62d389e 100644 --- a/classification/rego/email_test.rego +++ b/classification/rego/email_test.rego @@ -1,13 +1,15 @@ package classifier_email -test_no_label { - output.column == "UNLABELED" with input as {"column":"invalid"} +import rego.v1 + +test_no_label if { + output.column == false with input as {"column":"invalid"} } -test_valid_email_com { - output.message == "EMAIL" with input as {"message":"me@me.com"} +test_valid_email_com if { + output.message == true with input as {"message":"me@me.com"} } -test_valid_email_us { - output.message == "EMAIL" with input as {"message":"me@state.pa.us"} +test_valid_email_us if { + output.message == true with input as {"message":"me@state.pa.us"} } diff --git a/classification/rego/first_name_test.rego b/classification/rego/first_name_test.rego index 6c16add..b8d4b9d 100644 --- a/classification/rego/first_name_test.rego +++ b/classification/rego/first_name_test.rego @@ -1,49 +1,51 @@ package classifier_first_name -test_fn_pattern { - output.first_name == "FIRST_NAME" with input as {"first_name":"John"} +import rego.v1 + +test_fn_pattern if { + output.first_name == true with input as {"first_name":"John"} } -test_fn_pattern { - output.first_name == "FIRST_NAME" with input as {"first_name":"Robert"} +test_fn_pattern if { + output.first_name == true with input as {"first_name":"Robert"} } -test_fn_pattern { - output.firstname == "FIRST_NAME" with input as {"firstname":"Robert"} +test_fn_pattern if { + output.firstname == true with input as {"firstname":"Robert"} } -test_fn_pattern { - output.firstName == "FIRST_NAME" with input as {"firstName":"Robert"} +test_fn_pattern if { + output.firstName == true with input as {"firstName":"Robert"} } -test_fn_pattern { - output.First_Name == "FIRST_NAME" with input as {"First_Name":"Robert"} +test_fn_pattern if { + output.First_Name == true with input as {"First_Name":"Robert"} } -test_fn_pattern { - output.FirstName == "FIRST_NAME" with input as {"FirstName":"Robert"} +test_fn_pattern if { + output.FirstName == true with input as {"FirstName":"Robert"} } -test_gn_pattern { - output.given_name == "FIRST_NAME" with input as {"given_name":"John"} +test_gn_pattern if { + output.given_name == true with input as {"given_name":"John"} } -test_gn_pattern { - output.given_name == "FIRST_NAME" with input as {"given_name":"Robert"} +test_gn_pattern if { + output.given_name == true with input as {"given_name":"Robert"} } -test_gn_pattern { - output.givenname == "FIRST_NAME" with input as {"givenname":"Robert"} +test_gn_pattern if { + output.givenname == true with input as {"givenname":"Robert"} } -test_gn_pattern { - output.givenName == "FIRST_NAME" with input as {"givenName":"Robert"} +test_gn_pattern if { + output.givenName == true with input as {"givenName":"Robert"} } -test_gn_pattern { - output.Given_Name == "FIRST_NAME" with input as {"Given_Name":"Robert"} +test_gn_pattern if { + output.Given_Name == true with input as {"Given_Name":"Robert"} } -test_gn_pattern { - output.GivenName == "FIRST_NAME" with input as {"GivenName":"Robert"} +test_gn_pattern if { + output.GivenName == true with input as {"GivenName":"Robert"} } diff --git a/classification/rego/full_name_test.rego b/classification/rego/full_name_test.rego index 78b39c5..7c779db 100644 --- a/classification/rego/full_name_test.rego +++ b/classification/rego/full_name_test.rego @@ -1,25 +1,27 @@ package classifier_full_name -test_fn_pattern { - output.full_name == "FULL_NAME" with input as {"full_name":"John"} +import rego.v1 + +test_fn_pattern if { + output.full_name == true with input as {"full_name":"John"} } -test_fn_pattern { - output.full_name == "FULL_NAME" with input as {"full_name":"Robert"} +test_fn_pattern if { + output.full_name == true with input as {"full_name":"Robert"} } -test_fn_pattern { - output.fullname == "FULL_NAME" with input as {"fullname":"Robert"} +test_fn_pattern if { + output.fullname == true with input as {"fullname":"Robert"} } -test_fn_pattern { - output.fullName == "FULL_NAME" with input as {"fullName":"Robert"} +test_fn_pattern if { + output.fullName == true with input as {"fullName":"Robert"} } -test_fn_pattern { - output.Full_Name == "FULL_NAME" with input as {"Full_Name":"Robert"} +test_fn_pattern if { + output.Full_Name == true with input as {"Full_Name":"Robert"} } -test_fn_pattern { - output.FullName == "FULL_NAME" with input as {"FullName":"Robert"} +test_fn_pattern if { + output.FullName == true with input as {"FullName":"Robert"} } diff --git a/classification/rego/ip_address_test.rego b/classification/rego/ip_address_test.rego index 3ab915d..6c68bf1 100644 --- a/classification/rego/ip_address_test.rego +++ b/classification/rego/ip_address_test.rego @@ -1,25 +1,27 @@ package classifier_ip_address -test_no_label { - output.column == "UNLABELED" with input as {"column":"invalid"} +import rego.v1 + +test_no_label if { + output.column == false with input as {"column":"invalid"} } -test_ipv4_google { - output.column == "IP_ADDRESS" with input as {"column":"8.8.8.8"} +test_ipv4_google if { + output.column == true with input as {"column":"8.8.8.8"} } -test_ipv4_localhost { - output.column == "IP_ADDRESS" with input as {"column":"127.0.0.1"} +test_ipv4_localhost if { + output.column == true with input as {"column":"127.0.0.1"} } -test_ipv4_internal { - output.column == "IP_ADDRESS" with input as {"column":"10.1.1.1"} +test_ipv4_internal if { + output.column == true with input as {"column":"10.1.1.1"} } -test_ipv6 { - output.column == "IP_ADDRESS" with input as {"column":"2001:db8:3333:4444:5555:6666:7777:8888"} +test_ipv6 if { + output.column == true with input as {"column":"2001:db8:3333:4444:5555:6666:7777:8888"} } -test_ipv6_google { - output.column == "IP_ADDRESS" with input as {"column":"2001:4860:4860::8888"} +test_ipv6_google if { + output.column == true with input as {"column":"2001:4860:4860::8888"} } diff --git a/classification/rego/last_name_test.rego b/classification/rego/last_name_test.rego index 6e9edaa..77962d9 100644 --- a/classification/rego/last_name_test.rego +++ b/classification/rego/last_name_test.rego @@ -1,49 +1,51 @@ package classifier_last_name -test_ln_pattern { - output.last_name == "LAST_NAME" with input as {"last_name":"John"} +import rego.v1 + +test_ln_pattern if { + output.last_name == true with input as {"last_name":"John"} } -test_ln_pattern { - output.last_name == "LAST_NAME" with input as {"last_name":"Robert"} +test_ln_pattern if { + output.last_name == true with input as {"last_name":"Robert"} } -test_ln_pattern { - output.lastname == "LAST_NAME" with input as {"lastname":"Robert"} +test_ln_pattern if { + output.lastname == true with input as {"lastname":"Robert"} } -test_ln_pattern { - output.lastName == "LAST_NAME" with input as {"lastName":"Robert"} +test_ln_pattern if { + output.lastName == true with input as {"lastName":"Robert"} } -test_ln_pattern { - output.Last_Name == "LAST_NAME" with input as {"Last_Name":"Robert"} +test_ln_pattern if { + output.Last_Name == true with input as {"Last_Name":"Robert"} } -test_ln_pattern { - output.LastName == "LAST_NAME" with input as {"LastName":"Robert"} +test_ln_pattern if { + output.LastName == true with input as {"LastName":"Robert"} } -test_sn_pattern { - output.sur_name == "LAST_NAME" with input as {"sur_name":"John"} +test_sn_pattern if { + output.sur_name == true with input as {"sur_name":"John"} } -test_sn_pattern { - output.sur_name == "LAST_NAME" with input as {"sur_name":"Robert"} +test_sn_pattern if { + output.sur_name == true with input as {"sur_name":"Robert"} } -test_sn_pattern { - output.surname == "LAST_NAME" with input as {"surname":"Robert"} +test_sn_pattern if { + output.surname == true with input as {"surname":"Robert"} } -test_sn_pattern { - output.surName == "LAST_NAME" with input as {"surName":"Robert"} +test_sn_pattern if { + output.surName == true with input as {"surName":"Robert"} } -test_sn_pattern { - output.Sur_Name == "LAST_NAME" with input as {"Sur_Name":"Robert"} +test_sn_pattern if { + output.Sur_Name == true with input as {"Sur_Name":"Robert"} } -test_sn_pattern { - output.SurName == "LAST_NAME" with input as {"SurName":"Robert"} +test_sn_pattern if { + output.SurName == true with input as {"SurName":"Robert"} } diff --git a/classification/rego/passport_test.rego b/classification/rego/passport_test.rego index 44fc4b3..d8f3ba4 100644 --- a/classification/rego/passport_test.rego +++ b/classification/rego/passport_test.rego @@ -1,65 +1,67 @@ package classifier_passport -test_passport_key { - output.passport == "PASSPORT" with input as {"passport":"not-a-passport-number"} +import rego.v1 + +test_passport_key if { + output.passport == true with input as {"passport":"not-a-passport-number"} } # United States -test_passport_pattern { - output.message == "PASSPORT" with input as {"message":"A12345678"} +test_passport_pattern if { + output.message == true with input as {"message":"A12345678"} } # Canada -test_passport_pattern { - output.message == "PASSPORT" with input as {"message":"G12345678"} +test_passport_pattern if { + output.message == true with input as {"message":"G12345678"} } # United Kingdom -test_passport_pattern { - output.message == "PASSPORT" with input as {"message":"GH1234567"} +test_passport_pattern if { + output.message == true with input as {"message":"GH1234567"} } # Australia -test_passport_pattern { - output.message == "PASSPORT" with input as {"message":"P12345678"} +test_passport_pattern if { + output.message == true with input as {"message":"P12345678"} } # India -test_passport_pattern { - output.message == "PASSPORT" with input as {"message":"P1234567"} +test_passport_pattern if { + output.message == true with input as {"message":"P1234567"} } # Germany -test_passport_pattern { - output.message == "PASSPORT" with input as {"message":"E12345678"} +test_passport_pattern if { + output.message == true with input as {"message":"E12345678"} } # China -test_passport_pattern { - output.message == "PASSPORT" with input as {"message":"E123456789"} +test_passport_pattern if { + output.message == true with input as {"message":"E123456789"} } # Japan -test_passport_pattern { - output.message == "PASSPORT" with input as {"message":"P1234567"} +test_passport_pattern if { + output.message == true with input as {"message":"P1234567"} } # South Korea -test_passport_pattern { - output.message == "PASSPORT" with input as {"message":"M12345678"} +test_passport_pattern if { + output.message == true with input as {"message":"M12345678"} } # Brazil -test_passport_pattern { - output.message == "PASSPORT" with input as {"message":"G12345678"} +test_passport_pattern if { + output.message == true with input as {"message":"G12345678"} } # Mexico -test_passport_pattern { - output.message == "PASSPORT" with input as {"message":"E12345678"} +test_passport_pattern if { + output.message == true with input as {"message":"E12345678"} } # South Africa (diplomat, standard covered by other countries) -test_passport_sa_pattern { - output.message == "PASSPORT" with input as {"message":"D123456789"} +test_passport_sa_pattern if { + output.message == true with input as {"message":"D123456789"} } diff --git a/classification/rego/phone_test.rego b/classification/rego/phone_test.rego index 73295ea..8aa04ea 100644 --- a/classification/rego/phone_test.rego +++ b/classification/rego/phone_test.rego @@ -1,13 +1,15 @@ package classifier_phone_number -test_no_label { - output.column == "UNLABELED" with input as {"column":"invalid"} +import rego.v1 + +test_no_label if { + output.column == false with input as {"column":"invalid"} } -test_valid_us_phone { - output.message == "PHONE" with input as {"message":"7175551212"} +test_valid_us_phone if { + output.message == true with input as {"message":"7175551212"} } -test_valid_us_phone { - output.message == "PHONE" with input as {"message":"17175551212"} +test_valid_us_phone if { + output.message == true with input as {"message":"17175551212"} } diff --git a/classification/rego/ssn_test.rego b/classification/rego/ssn_test.rego index 7f6a8d5..ba776c2 100644 --- a/classification/rego/ssn_test.rego +++ b/classification/rego/ssn_test.rego @@ -1,73 +1,75 @@ package classifier_ssn -test_no_label { - output.column == "UNLABELED" with input as {"column":"invalid"} +import rego.v1 + +test_no_label if { + output.column == false with input as {"column":"invalid"} } -test_invalid_first_000 { - output.column == "UNLABELED" with input as {"column":"000123456"} +test_invalid_first_000 if { + output.column == false with input as {"column":"000123456"} } -test_invalid_first_666 { - output.column == "UNLABELED" with input as {"column":"666123456"} +test_invalid_first_666 if { + output.column == false with input as {"column":"666123456"} } -test_invalid_first_900s { - output.column == "UNLABELED" with input as {"column":"905123456"} +test_invalid_first_900s if { + output.column == false with input as {"column":"905123456"} } -test_invalid_middle { - output.column == "UNLABELED" with input as {"column":"123006789"} +test_invalid_middle if { + output.column == false with input as {"column":"123006789"} } -test_invalid_end { - output.column == "UNLABELED" with input as {"column":"123450000"} +test_invalid_end if { + output.column == false with input as {"column":"123450000"} } -test_ssn_on_valid_amex_ccn { - output.message == "UNLABELED" with input as {"message":"370136066365291"} +test_ssn_on_valid_amex_ccn if { + output.message == false with input as {"message":"370136066365291"} } -test_ssn_on_valid_amex_ccn { - output.message == "UNLABELED" with input as {"message":"370136066365291"} +test_ssn_on_valid_amex_ccn if { + output.message == false with input as {"message":"370136066365291"} } -test_ssn_on_valid_visa_ccn { - output.message == "UNLABELED" with input as {"message":"4613688275707134"} +test_ssn_on_valid_visa_ccn if { + output.message == false with input as {"message":"4613688275707134"} } -test_ssn_on_valid_mastercard_format_1_ccn { - output.message == "UNLABELED" with input as {"message":"5423909386888564"} +test_ssn_on_valid_mastercard_format_1_ccn if { + output.message == false with input as {"message":"5423909386888564"} } -test_ssn_on_valid_mastercard_format_2_ccn { - output.message == "UNLABELED" with input as {"message":"2701306282695666"} +test_ssn_on_valid_mastercard_format_2_ccn if { + output.message == false with input as {"message":"2701306282695666"} } -test_ssn_on_valid_discover_ccn { - output.message == "UNLABELED" with input as {"message":"6536673682309236"} +test_ssn_on_valid_discover_ccn if { + output.message == false with input as {"message":"6536673682309236"} } -test_valid_ssn_dashes { - output.message == "SSN" with input as {"message":"111-11-1111"} +test_valid_ssn_dashes if { + output.message == true with input as {"message":"111-11-1111"} } -test_valid_ssn_dashes_sequential { - output.message == "SSN" with input as {"message":"123-45-6789"} +test_valid_ssn_dashes_sequential if { + output.message == true with input as {"message":"123-45-6789"} } -test_valid_ssn_dashes_in_value { - output.message == "SSN" with input as {"message":"this has a ssn 111-11-1111 that is valid"} +test_valid_ssn_dashes_in_value if { + output.message == true with input as {"message":"this has a ssn 111-11-1111 that is valid"} } -test_valid_ssn_no_dashes { - output.message == "SSN" with input as {"message":"111111111"} +test_valid_ssn_no_dashes if { + output.message == true with input as {"message":"111111111"} } -test_valid_ssn_no_dashes_sequential { - output.message == "SSN" with input as {"message":"123456789"} +test_valid_ssn_no_dashes_sequential if { + output.message == true with input as {"message":"123456789"} } -test_valid_ssn_no_dashes_in_value { - output.message == "SSN" with input as {"message":"this has a ssn 111111111 that is valid"} +test_valid_ssn_no_dashes_in_value if { + output.message == true with input as {"message":"this has a ssn 111111111 that is valid"} } diff --git a/discovery/repository/snowflake/snowflake.go b/discovery/repository/snowflake/snowflake.go index 9dfa583..2221f9c 100644 --- a/discovery/repository/snowflake/snowflake.go +++ b/discovery/repository/snowflake/snowflake.go @@ -58,7 +58,7 @@ func NewSnowflakeRepository(_ context.Context, repoCfg config.RepoConfig) (repos sqlRepo, err := genericsql.NewGenericSqlRepository( repoCfg.Host, RepoTypeSnowflake, - repoCfg.Database, + database, connStr, repoCfg.MaxOpenConns, repoCfg.IncludePaths,