fix: hardening
This commit is contained in:
19 files changed
+486
-119
No files matched your search
@@ -3,6 +3,7 @@
|
||||
import base64
|
||||
import json
|
||||
import unittest
|
||||
import urllib.parse
|
||||
|
||||
import proxy_parsing
|
||||
from proxy_parsing import build_outbound
|
||||
@@ -141,6 +142,29 @@ class BuildOutboundTests(unittest.TestCase):
|
||||
self.assertEqual(ob["streamSettings"]["network"], "xhttp")
|
||||
self.assertEqual(ob["streamSettings"]["xhttpSettings"]["path"], "/x")
|
||||
|
||||
def test_xray_xhttp_extra_keeps_ordinary_settings(self):
|
||||
extra = json.dumps({"xPaddingBytes": "100-1000", "downloadSettings": {"address": "dl.example.com"}})
|
||||
ob = run_xray_parser(
|
||||
"vless://uuid@example.com:443?type=xhttp&security=tls&sni=cdn.example.com&extra="
|
||||
+ urllib.parse.quote(extra)
|
||||
)
|
||||
self.assertEqual(ob["streamSettings"]["xhttpSettings"]["extra"]["xPaddingBytes"], "100-1000")
|
||||
|
||||
def test_xray_xhttp_extra_cannot_name_local_files(self):
|
||||
# XRay holds CAP_NET_ADMIN: a subscription must not make it write masterKeyLog or read a key.
|
||||
extra = json.dumps(
|
||||
{
|
||||
"downloadSettings": {
|
||||
"tlsSettings": {"masterKeyLog": "/etc/x", "certificates": [{"keyFile": "/root/k"}]}
|
||||
}
|
||||
}
|
||||
)
|
||||
with self.assertRaisesRegex(ValueError, "keyfile, masterkeylog"):
|
||||
run_xray_parser(
|
||||
"vless://uuid@example.com:443?type=xhttp&security=tls&sni=cdn.example.com&extra="
|
||||
+ urllib.parse.quote(extra)
|
||||
)
|
||||
|
||||
def test_xray_vless_ech(self):
|
||||
ob = run_xray_parser(
|
||||
"vless://uuid@example.com:443?type=tcp&security=tls&sni=cdn.example.com&ech=udp%3A%2F%2F1.1.1.1"
|
||||
|
||||
Reference in new issue
Block a user