Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] - Find personnummer & check vs skatteverkets list #7

Open
peter-c-larsson opened this issue Feb 28, 2022 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@peter-c-larsson
Copy link

Description

I had help with this script here and what I did to scan our code base for personnummer was a regex that looks like this:

REG_EX="(18|19|20|)\d{2}(0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[0-1])-?\d{4}"
grep -r -e "$REG_EX" .

The code I used to download all skatteverkets personnummer:

#!/bin/bash
# Based on the API here: https://skatteverket.entryscape.net/rowstore/dataset/b4de7df7-63c0-4e7e-bb59-1f156a591763/html
RESULTFILE=personnummer-skatteverket.txt
LIMIT=500
rm "$RESULTFILE" || echo "File doesn't exist"
for ((i=0; ; i+=LIMIT)); do
    echo "Working with offset $i"
    contents=$(curl -s -H 'Content-Type: application/json' "https://skatteverket.entryscape.net/rowstore/dataset/b4de7df7-63c0-4e7e-bb59-1f156a591763?_offset=$i&_limit=$LIMIT")
    if jq -e '.results | length == 0' >/dev/null; then
       break
    fi <<< "$contents"
    echo "$contents" | jq --raw-output '.results[] | .testpersonnummer' >> "$RESULTFILE"
done
echo "Entries collected: $(wc -l $RESULTFILE)"

With the help of these two components and the valid script here I could easily check all our code for personnummer that is is valid and if they match skatteverkets list.

Suggestion would be to add these features to this repository and I can create PR if there is interest.

Breaking changes

Nope

@peter-c-larsson peter-c-larsson added the enhancement New feature or request label Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant