38 lines
1.9 KiB
Python
Executable File
38 lines
1.9 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Source-only regression guards for the OPT3 patch (NOT a Rust compile)."""
|
|
from pathlib import Path
|
|
root = Path(__file__).resolve().parents[2]
|
|
|
|
def read(name):
|
|
return (root / name).read_text(encoding='utf-8')
|
|
|
|
assert 'version = "0.34.0"' in read('Cargo.toml')
|
|
acl = read('src/acl.rs')
|
|
assert "pub fn routing_path_view(raw: &str)" in acl
|
|
assert "return routing_path(raw).map(std::borrow::Cow::Owned)" in acl
|
|
assert 'raw.split' in acl and 'raw.len() <= 8192' in acl
|
|
forward = read('src/proxy/forward_entry.rs')
|
|
assert 'let routing_uri = request.uri().clone();' in forward
|
|
assert 'crate::acl::routing_path_view(routing_uri.path())' in forward
|
|
assert 'if context.client_ip != peer.0.ip()' in forward
|
|
route = read('src/proxy/cache_helpers.rs')
|
|
assert 'crate::acl::routing_path_view(request.uri().path())' in route
|
|
for name in ('src/proxy/forward/cache_lookup.rs', 'src/proxy/forward/success_finish.rs', 'src/proxy/forward/web_source.rs'):
|
|
assert 'path.clone()' not in read(name), name
|
|
assert 'if !trusted_peer' in read('src/forwarding.rs')
|
|
assert 'let mut ips = chain(incoming).unwrap_or_default();' in read('src/forwarding.rs')
|
|
headers = read('src/proxy/headers.rs')
|
|
assert 'let only_keep_alive' in headers
|
|
assert 'let nominated: Vec<HeaderName>' in headers
|
|
assert 'headers.remove(name)' in headers
|
|
assert 'String::from_utf8(encoded)' in read('src/proxy/request_id.rs')
|
|
assert 'if reason == "cache_disabled"' in read('src/cache/stats.rs')
|
|
assert not read('src/cache/stats.rs').startswith('//!') # previous E0753 build issue
|
|
for name in ('src/acl/tests.rs', 'src/proxy/headers/tests.rs', 'src/forwarding/tests.rs'):
|
|
assert (root / name).exists()
|
|
for source in (root / 'src').rglob('*.rs'):
|
|
if '/tests/' in source.as_posix() or source.name == 'tests.rs':
|
|
continue
|
|
assert len(source.read_text(encoding='utf-8').splitlines()) <= 500, source
|
|
print('PASS OPT3 source guards (STATIC ONLY; not cargo check, live HTTP or throughput)')
|