Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
Whitelisting of CPR numbers now works.
Browse files Browse the repository at this point in the history
  • Loading branch information
agger-magenta committed Jan 28, 2016
1 parent f8d5fd5 commit cc55096
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -8,3 +8,4 @@ django-os2webscanner/django.os2webscanner.egg-info
*.egg-info
/webscanner_site/webscanner/local_settings.py
/scrapy-webscanner/scanner/local_settings.py
.ropeproject
Expand Up @@ -155,7 +155,7 @@ <h2>Resultater</h2>
Side
</small>
</strong>
</td>a
</td>
{% endif %}
</tr>
</thead>
Expand Down
5 changes: 3 additions & 2 deletions scrapy-webscanner/scanner/rules/cpr.py
Expand Up @@ -50,7 +50,8 @@ def __init__(self, do_modulus11, ignore_irrelevant, whitelist=None):
def execute(self, text):
"""Execute the CPR rule."""
matches = match_cprs(text, do_modulus11=self.do_modulus11,
ignore_irrelevant=self.ignore_irrelevant)
ignore_irrelevant=self.ignore_irrelevant,
whitelist=self.whitelist)
return matches

# TODO: Improve
Expand Down Expand Up @@ -167,7 +168,7 @@ def modulus11_check(cpr):


def match_cprs(text, do_modulus11=True, ignore_irrelevant=True,
mask_digits=True):
mask_digits=True, whitelist=[]):
"""Return MatchItem objects for each CPR matched in the given text.
If mask_digits is False, then the matches will contain full CPR numbers.
Expand Down
8 changes: 4 additions & 4 deletions scrapy-webscanner/scanner/scanner/scanner.py
Expand Up @@ -42,10 +42,10 @@ def _load_rules(self):
"""Load rules based on Scanner settings."""
rules = []
if self.scan_object.do_cpr_scan:
rules.append(
CPRRule(
do_modulus11=self.scan_object.do_cpr_modulus11,
ignore_irrelevant=self.scan_object.do_cpr_ignore_irrelevant
rules.append(CPRRule(
do_modulus11=self.scan_object.do_cpr_modulus11,
ignore_irrelevant=self.scan_object.do_cpr_ignore_irrelevant,
whitelist=self.scan_object.whitelisted_cprs
)
)
if self.scan_object.do_name_scan:
Expand Down
2 changes: 1 addition & 1 deletion sql/updates/20160127.sql
@@ -1,2 +1,2 @@
ALTER TABLE os2webscanner_organization ADD "cpr_whitelist" text NOT NULL DEFAULT '';
ALTER TABLE os2webscanner_scanner ADD "whitelisted_cprs" text NOT NULL DEFAULT '';
ALTER TABLE os2webscanner_scan ADD "whitelisted_cprs" text NOT NULL DEFAULT '';

0 comments on commit cc55096

Please sign in to comment.