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

readme & dns #203

Merged
merged 6 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion .github/workflows/scripts/technology_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,26 @@ def get_type(self) -> list[Type]:
return [dict]


class DNSValidator(DictValidator):
def _validate(self, tech_name: str, data: Any) -> bool:
if not super()._validate(tech_name, data):
return False
for k, v in data.items():
if not isinstance(k, str):
self._set_custom_error(InvalidKeyException(f"key in DNS for tech '{tech_name}' has an invalid type. 'str' is required, got type '{type(k).__name__}' -> '{k}'"))
return False
if not isinstance(v, list):
self._set_custom_error(InvalidKeyException(f"value in DNS for tech '{tech_name}' has an invalid type. 'list' is required, got type '{type(v).__name__}' -> '{v}'"))
return False
for record in v:
if not isinstance(record, str):
self._set_custom_error(InvalidTypeForFieldException(f"Invalid type for dns in tech '{tech_name}', selector '{v}' '{record}' key must be string!"))
return False
if not self._validate_regex(tech_name, record):
return False
return True


class CategoryValidator(ArrayValidator):
def __init__(self, categories: list[int], required: bool = False):
super().__init__(required)
Expand Down Expand Up @@ -323,7 +343,7 @@ def __init__(self, file_name: str):
"requiresCategory": CategoryValidator(self._CATEGORIES),
"cookies": DictValidator(contains_regex=True),
"dom": DomValidator(),
"dns": DictValidator(contains_regex=True),
"dns": DNSValidator(contains_regex=True),
"js": DictValidator(contains_regex=True),
"headers": DictValidator(contains_regex=True),
"text": ArrayValidator(contains_regex=True),
Expand Down
Loading