verifiers 0.3.2.dev154__py3-none-any.whl → 0.3.2.dev155__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,7 +19,9 @@ def parse_network_rule(rule: str) -> tuple[SplitResult, str, int | None]:
19
19
  return parsed, (parsed.hostname or "").lower().rstrip("."), port
20
20
 
21
21
 
22
- def network_rule_matches(rule: str, scheme: str, host: str, port: int) -> bool:
22
+ def network_rule_matches(
23
+ rule: str, scheme: str, host: str, port: int, *, subdomains: bool = False
24
+ ) -> bool:
23
25
  """Match a network-policy host pattern or URL origin. Paths are ignored."""
24
26
  try:
25
27
  parsed, pattern, rule_port = parse_network_rule(rule)
@@ -30,9 +32,7 @@ def network_rule_matches(rule: str, scheme: str, host: str, port: int) -> bool:
30
32
  if rule_port is not None and rule_port != port:
31
33
  return False
32
34
  host = host.lower().rstrip(".")
33
- return fnmatchcase(host, pattern) or (
34
- pattern.startswith("*.") and host == pattern[2:]
35
- )
35
+ return fnmatchcase(host, pattern) or (subdomains and host.endswith(f".{pattern}"))
36
36
 
37
37
 
38
38
  def intersect_network_hosts(left: str, right: str) -> str:
@@ -45,7 +45,7 @@ def intersect_network_hosts(left: str, right: str) -> str:
45
45
  parent.startswith("*.") and not has_magic(parent[2:])
46
46
  ):
47
47
  continue
48
- if fnmatchcase(child, parent) or child == parent.removeprefix("*."):
48
+ if fnmatchcase(child, parent):
49
49
  return child
50
50
  if all(has_magic(host) for host in (left, right)) and any(
51
51
  has_magic(host.removeprefix("*.")) for host in (left, right)
@@ -61,7 +61,8 @@ class NetworkPolicyConfig(BaseConfig):
61
61
  """Destinations allowed during execution; `*` is unrestricted and `[]` is
62
62
  framework-only."""
63
63
  block: list[str] = Field(default_factory=list)
64
- """Destinations denied during execution; any `*` makes the policy framework-only."""
64
+ """Denied destinations; bare domains include subdomains, `*.` excludes the base
65
+ domain, and any `*` makes the policy framework-only."""
65
66
 
66
67
  @model_validator(mode="after")
67
68
  def validate_network_policy(self) -> Self:
@@ -82,7 +83,8 @@ class NetworkPolicyConfig(BaseConfig):
82
83
  def permits(self, scheme: str, host: str, port: int) -> bool:
83
84
  """Whether the destination is allowed by the configured egress rules."""
84
85
  return not any(
85
- network_rule_matches(rule, scheme, host, port) for rule in self.block
86
+ network_rule_matches(rule, scheme, host, port, subdomains=True)
87
+ for rule in self.block
86
88
  ) and any(network_rule_matches(rule, scheme, host, port) for rule in self.allow)
87
89
 
88
90
  def with_task_network_policy(self, allow: list[str], block: list[str]) -> Self:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: verifiers
3
- Version: 0.3.2.dev154
3
+ Version: 0.3.2.dev155
4
4
  Summary: Verifiers: Environments for LLM Reinforcement Learning
5
5
  Project-URL: Homepage, https://github.com/primeintellect-ai/verifiers
6
6
  Project-URL: Documentation, https://github.com/primeintellect-ai/verifiers
@@ -48,7 +48,7 @@ verifiers/v1/configs/env.py,sha256=k47XBYYWLOf-8P1dbek3x_s0ucNb726xxoryG69DIr4,7
48
48
  verifiers/v1/configs/harness.py,sha256=ZrR-Egzfft95oMoqQ78bAq9TqP882Q68M_47Ajw9lE8,2918
49
49
  verifiers/v1/configs/judge.py,sha256=WEwA8D4X5JSaIP3c-E2wPnvgByWeT6JRAn1d8gfiQ40,2142
50
50
  verifiers/v1/configs/retries.py,sha256=-nPlgmz7J_NZ4GOYG6oCc3thXo4La2SufBmvQGvvPGo,821
51
- verifiers/v1/configs/runtime.py,sha256=ZEGx5JEgkMOLBQhiKAg6nzqKMhUu4W9tCE3AR--X8HY,5412
51
+ verifiers/v1/configs/runtime.py,sha256=3LDAnKy-BotE6MqyT1l07Y_bAq9Wye1OU8JZ7lyUVvY,5474
52
52
  verifiers/v1/configs/select.py,sha256=_HdcepQaJ1sDCYcs7Vqx72npDwHGOgUjsLDZmcgnonU,4743
53
53
  verifiers/v1/configs/serve.py,sha256=oa_0BrAVEKboU344w0hYkSaXj8lf26t0H87gvncAo0Q,2716
54
54
  verifiers/v1/configs/task.py,sha256=57OnEGAa6jTiG12Lx_elREU02koYh8UkM0t0Vvxahys,2614
@@ -193,8 +193,8 @@ verifiers/v1/utils/scope.py,sha256=bzUEiWDOVdbj7dXOwGOlzsQ_-Xu0j9NR5TalQB-8TS8,8
193
193
  verifiers/v1/utils/score.py,sha256=493yJVMw8teCu9JxapxMFPFzI0hNUqdo0Y2nGW4kckk,6200
194
194
  verifiers/v1/utils/trace_store.py,sha256=RsCDonGR-bs-tvEstcppiJm3jFmAdIiG83fA5KtCbAw,2801
195
195
  verifiers/v1/utils/version.py,sha256=-obEo_-l9-D8FLef4hYxncOe-uJpxrM1g2Hig_37Sgs,1607
196
- verifiers-0.3.2.dev154.dist-info/METADATA,sha256=PCpfeUDas7lHnPiFDRXfbqrDs-QW5R2FHsxwOdEnAaM,4161
197
- verifiers-0.3.2.dev154.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
198
- verifiers-0.3.2.dev154.dist-info/entry_points.txt,sha256=iugElcdWPKbQM7uFF0lZ8iUpHsNr17-BwEAAjJWxV3U,259
199
- verifiers-0.3.2.dev154.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
200
- verifiers-0.3.2.dev154.dist-info/RECORD,,
196
+ verifiers-0.3.2.dev155.dist-info/METADATA,sha256=_8FL9NqqyE2TxMxg99xcayYl67d8IEYE_vwHoYGI6kY,4161
197
+ verifiers-0.3.2.dev155.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
198
+ verifiers-0.3.2.dev155.dist-info/entry_points.txt,sha256=iugElcdWPKbQM7uFF0lZ8iUpHsNr17-BwEAAjJWxV3U,259
199
+ verifiers-0.3.2.dev155.dist-info/licenses/LICENSE,sha256=v0RrUsdV3IDoZhrRce297IXS3xMHNJ-_LdLpFAUWb9k,1072
200
+ verifiers-0.3.2.dev155.dist-info/RECORD,,