From 6e5adb8801cfba9664e0623dbf41846463951690 Mon Sep 17 00:00:00 2001 From: Iain Learmonth Date: Sun, 29 Oct 2023 19:28:21 +0000 Subject: [PATCH] feat: update mirror mapping schema for version 1.2 --- app/lists/mirror_mapping.py | 11 ++++--- schemas/bridgelines.json | 11 ++++--- schemas/mirror-mapping.json | 65 ++++++++++++++++++++++++++++++++++--- 3 files changed, 73 insertions(+), 14 deletions(-) diff --git a/app/lists/mirror_mapping.py b/app/lists/mirror_mapping.py index 248a599..83094c5 100644 --- a/app/lists/mirror_mapping.py +++ b/app/lists/mirror_mapping.py @@ -20,9 +20,10 @@ class MMMirror(BaseModel): origin_domain_root: str = Field(description="The registered domain name of the origin, excluding subdomains") valid_from: str = Field(description="The date on which the mirror was added to the system") valid_to: Optional[str] = Field(description="The date on which the mirror was decommissioned") - # countries: List[Tuple[str, int]] = Field(description="A list mapping of risk levels to country") - country: Optional[str] = Field(description="The country code of the country in which the origin is targeted") - risk: int = Field(description="A risk score for the origin in the target country") + countries: Dict[str, int] = Field(description="A list mapping of risk levels to country") + country: Optional[str] = Field( + description="The country code of the country with the highest risk level where the origin is targeted") + risk: int = Field(description="The risk score for the highest risk country") class MirrorMapping(BaseModel): @@ -37,7 +38,7 @@ class MirrorMapping(BaseModel): ) class Config: - title = "Mirror Mapping Version 1.1" + title = "Mirror Mapping Version 1.2" def mirror_mapping(_: Optional[Pool]) -> Dict[str, Union[str, Dict[str, str]]]: @@ -67,7 +68,7 @@ def mirror_mapping(_: Optional[Pool]) -> Dict[str, Union[str, Dict[str, str]]]: origin_domain_root=extract(proxy.origin.domain_name).registered_domain, valid_from=proxy.added.isoformat(), valid_to=proxy.destroyed.isoformat() if proxy.destroyed is not None else None, - # countries=[], # TODO: countries, + countries=proxy.origin.risk_level, country=highest_risk_country_code, risk=highest_risk_level ) diff --git a/schemas/bridgelines.json b/schemas/bridgelines.json index 427d896..9a89515 100644 --- a/schemas/bridgelines.json +++ b/schemas/bridgelines.json @@ -1,19 +1,22 @@ { - "title": "Bridgelines Version 2", + "title": "Bridgelines Version 1", "type": "object", "properties": { "version": { "title": "Version", "description": "Version number of the bridgelines schema in use", + "examples": [ + "1.0" + ], "type": "string" }, "bridgelines": { "title": "Bridgelines", "description": "List of bridgelines, ready for use in a torrc file", "examples": [ - "obfs4 71.73.124.31:8887 E81B1237F6D13497B166060F55861565593CFF8E cert=b54NsV6tK1g+LHaThPOTCibdpx3wHm9NFe0PzGF1nwz+4M/tq6SkfOaShzPnZsIRCFRIHg iat-mode=0", - "obfs4 172.105.176.101:80 D18BC7E082D7EBF8E851029AC89A12A3F44A50BF cert=KHfAAUptXWRmLy3ehS9ETMO5luY06d0w7tEBDiAI0z62nC5Qo/APrzZxodkYWX2bNko/Mw iat-mode=0", - "obfs4 141.101.36.55:9023 045EF272F08BC11CDB985889E4E9FE35DC6F9C67 cert=6KEdf/5aDSyuYEqvo14JE8Cks3i7PQtj9EFX2wTCiEaUPsp/I7eaOm4uSWdqwvV4vTVlFw iat-mode=0" + "Bridge obfs4 71.73.124.31:8887 E81B1237F6D13497B166060F55861565593CFF8E cert=b54NsV6tK1g+LHaThPOTCibdpx3wHm9NFe0PzGF1nwz+4M/tq6SkfOaShzPnZsIRCFRIHg iat-mode=0", + "Bridge obfs4 172.105.176.101:80 D18BC7E082D7EBF8E851029AC89A12A3F44A50BF cert=KHfAAUptXWRmLy3ehS9ETMO5luY06d0w7tEBDiAI0z62nC5Qo/APrzZxodkYWX2bNko/Mw iat-mode=0", + "Bridge obfs4 141.101.36.55:9023 045EF272F08BC11CDB985889E4E9FE35DC6F9C67 cert=6KEdf/5aDSyuYEqvo14JE8Cks3i7PQtj9EFX2wTCiEaUPsp/I7eaOm4uSWdqwvV4vTVlFw iat-mode=0 " ], "type": "array", "items": { diff --git a/schemas/mirror-mapping.json b/schemas/mirror-mapping.json index 5d656f8..27cda53 100644 --- a/schemas/mirror-mapping.json +++ b/schemas/mirror-mapping.json @@ -1,10 +1,34 @@ { - "title": "Mirror Mapping Version 1", - "description": "The domain name for the mirror", + "title": "Mirror Mapping Version 1.2", "type": "object", - "additionalProperties": { - "$ref": "#/definitions/MMMirror" + "properties": { + "version": { + "title": "Version", + "description": "Version number of the mirror mapping schema in use", + "type": "string" + }, + "mappings": { + "title": "Mappings", + "description": "The domain name for the mirror", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/MMMirror" + } + }, + "s3_buckets": { + "title": "S3 Buckets", + "description": "The names of all S3 buckets used for CloudFront logs", + "type": "array", + "items": { + "type": "string" + } + } }, + "required": [ + "version", + "mappings", + "s3_buckets" + ], "definitions": { "MMMirror": { "title": "MMMirror", @@ -24,12 +48,43 @@ "title": "Origin Domain Root", "description": "The registered domain name of the origin, excluding subdomains", "type": "string" + }, + "valid_from": { + "title": "Valid From", + "description": "The date on which the mirror was added to the system", + "type": "string" + }, + "valid_to": { + "title": "Valid To", + "description": "The date on which the mirror was decommissioned", + "type": "string" + }, + "countries": { + "title": "Countries", + "description": "A list mapping of risk levels to country", + "type": "object", + "additionalProperties": { + "type": "integer" + } + }, + "country": { + "title": "Country", + "description": "The country code of the country with the highest risk level where the origin is targeted", + "type": "string" + }, + "risk": { + "title": "Risk", + "description": "The risk score for the highest risk country", + "type": "integer" } }, "required": [ "origin_domain", "origin_domain_normalized", - "origin_domain_root" + "origin_domain_root", + "valid_from", + "countries", + "risk" ] } }