Skip to content

Commit

Permalink
Removed SCRUBBER_VALIDATION_WHITELIST in favour of `SCRUBBER_REQUIR…
Browse files Browse the repository at this point in the history
…ED_FIELD_MODEL_WHITELIST`
  • Loading branch information
GitRon committed Sep 8, 2024
1 parent b882085 commit 921e263
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 20 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
<!--
## [Unreleased]
-
- Removed `SCRUBBER_VALIDATION_WHITELIST` in favour of `SCRUBBER_REQUIRED_FIELD_MODEL_WHITELIST`
- Added Django test model `db.TestModel` to default whitelist of `SCRUBBER_REQUIRED_FIELD_MODEL_WHITELIST`
-->

## [2.1.0] - 2024-08-20
Expand Down
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ activating the strict mode. Defaults to the non-privacy-related Django base mode
Items can either be full model names (e.g. `auth.Group`) or regular expression patterns matching
against the full model name (e.g. `re.compile(auth.*)` to whitelist all auth models).

(default: ['auth.Group', 'auth.Permission', 'contenttypes.ContentType', 'sessions.Session', 'sites.Site',
'django_scrubber.FakeData',))
(default: `('auth.Group', 'auth.Permission', 'contenttypes.ContentType', 'sessions.Session', 'sites.Site',
'django_scrubber.FakeData', 'db.TestModel',)`)

````python
SCRUBBER_MAPPING = {
Expand All @@ -322,12 +322,6 @@ SCRUBBER_MAPPING = {

(default: {})

### `SCRUBBER_VALIDATION_WHITELIST`:

Whitelist models you want to exclude from the `scrub_validation` checker command for scrubber-wise undeclared models.
By default, it contains only a test model from Django core which doesn't have to be anonymised.

(default: ['db.TestModel',])

## Logging

Expand Down
4 changes: 1 addition & 3 deletions django_scrubber/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@
'auth.Group',
'auth.Permission',
'contenttypes.ContentType',
'db.TestModel',
'sessions.Session',
'sites.Site',
'django_scrubber.FakeData',
],
'SCRUBBER_VALIDATION_WHITELIST': [
'db.TestModel', # Test model from Django core
],
}


Expand Down
8 changes: 0 additions & 8 deletions django_scrubber/management/commands/scrub_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from django.core.management.base import BaseCommand

from django_scrubber import settings_with_fallback
from django_scrubber.services.validator import ScrubberValidatorService


Expand All @@ -15,16 +14,9 @@ def handle(self, *args, **options):
found_models = 0
found_fields = 0

whitelisted_models = settings_with_fallback('SCRUBBER_VALIDATION_WHITELIST')

if len(non_scrubbed_field_list):
for model_path, affected_field_list in non_scrubbed_field_list.items():

if model_path in whitelisted_models:
print(f'Model {model_path!r} was excluded via \'SCRUBBER_VALIDATION_WHITELIST\' and will '
'not be validated.')
continue

print(f'Model {model_path!r}:')
found_models += 1
for field in affected_field_list:
Expand Down

0 comments on commit 921e263

Please sign in to comment.