4
0

types.py 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. from typing import TypedDict
  2. class ACLTypeInfo(TypedDict):
  3. category: str
  4. slow: bool
  5. desc: str
  6. ACL_TYPES_INFO: dict[str, ACLTypeInfo] = {
  7. # Network ACLs
  8. "src": {
  9. "category": "network",
  10. "slow": False,
  11. "desc": "Source IP address",
  12. },
  13. "dst": {
  14. "category": "network",
  15. "slow": True,
  16. "desc": "Destination IP address",
  17. },
  18. "localip": {
  19. "category": "network",
  20. "slow": False,
  21. "desc": "Local IP client connected to",
  22. },
  23. "arp": {
  24. "category": "network",
  25. "slow": False,
  26. "desc": "MAC address (EUI-48)",
  27. },
  28. "eui64": {
  29. "category": "network",
  30. "slow": False,
  31. "desc": "EUI-64 address",
  32. },
  33. "client_connection_mark": {
  34. "category": "network",
  35. "slow": False,
  36. "desc": "CONNMARK of connection",
  37. },
  38. # Domain ACLs
  39. "srcdomain": {
  40. "category": "domain",
  41. "slow": True,
  42. "desc": "Reverse DNS lookup of client IP",
  43. },
  44. "dstdomain": {
  45. "category": "domain",
  46. "slow": False,
  47. "desc": "Destination domain from URL",
  48. },
  49. "srcdom_regex": {
  50. "category": "domain",
  51. "slow": True,
  52. "desc": "Regex match on client name",
  53. },
  54. "dstdom_regex": {
  55. "category": "domain",
  56. "slow": False,
  57. "desc": "Regex match on server domain",
  58. },
  59. # AS Number ACLs
  60. "src_as": {
  61. "category": "network",
  62. "slow": False,
  63. "desc": "Source Autonomous System number",
  64. },
  65. "dst_as": {
  66. "category": "network",
  67. "slow": False,
  68. "desc": "Destination AS number",
  69. },
  70. # Time ACLs
  71. "time": {
  72. "category": "time",
  73. "slow": False,
  74. "desc": "Time of day and day of week",
  75. },
  76. # URL ACLs
  77. "url_regex": {
  78. "category": "url",
  79. "slow": False,
  80. "desc": "Regex match on full URL",
  81. },
  82. "urllogin": {
  83. "category": "url",
  84. "slow": False,
  85. "desc": "Regex match on URL login field",
  86. },
  87. "urlpath_regex": {
  88. "category": "url",
  89. "slow": False,
  90. "desc": "Regex match on URL path",
  91. },
  92. # Port ACLs
  93. "port": {
  94. "category": "port",
  95. "slow": False,
  96. "desc": "Destination TCP port",
  97. },
  98. "localport": {
  99. "category": "port",
  100. "slow": False,
  101. "desc": "TCP port client connected to",
  102. },
  103. "myportname": {
  104. "category": "port",
  105. "slow": False,
  106. "desc": "Port name from *_port directive",
  107. },
  108. # Protocol & Method ACLs
  109. "proto": {
  110. "category": "protocol",
  111. "slow": False,
  112. "desc": "Request protocol (HTTP, FTP, etc)",
  113. },
  114. "method": {
  115. "category": "protocol",
  116. "slow": False,
  117. "desc": "HTTP request method",
  118. },
  119. "http_status": {
  120. "category": "protocol",
  121. "slow": False,
  122. "desc": "HTTP status code in reply",
  123. },
  124. # Header ACLs
  125. "browser": {
  126. "category": "content",
  127. "slow": False,
  128. "desc": "User-Agent header pattern",
  129. },
  130. "referer_regex": {
  131. "category": "content",
  132. "slow": False,
  133. "desc": "Referer header pattern",
  134. },
  135. "req_header": {
  136. "category": "content",
  137. "slow": False,
  138. "desc": "Request header pattern",
  139. },
  140. "rep_header": {
  141. "category": "content",
  142. "slow": False,
  143. "desc": "Reply header pattern",
  144. },
  145. # Authentication ACLs
  146. "proxy_auth": {
  147. "category": "auth",
  148. "slow": True,
  149. "desc": "Proxy authentication username",
  150. },
  151. "proxy_auth_regex": {
  152. "category": "auth",
  153. "slow": True,
  154. "desc": "Proxy auth username regex",
  155. },
  156. "ext_user": {
  157. "category": "auth",
  158. "slow": True,
  159. "desc": "External ACL helper username",
  160. },
  161. "ext_user_regex": {
  162. "category": "auth",
  163. "slow": True,
  164. "desc": "External ACL helper username regex",
  165. },
  166. # MIME Type ACLs
  167. "req_mime_type": {
  168. "category": "content",
  169. "slow": False,
  170. "desc": "Request MIME type",
  171. },
  172. "rep_mime_type": {
  173. "category": "content",
  174. "slow": False,
  175. "desc": "Reply MIME type",
  176. },
  177. # Connection ACLs
  178. "maxconn": {
  179. "category": "connection",
  180. "slow": False,
  181. "desc": "Max TCP connections from IP",
  182. },
  183. "max_user_ip": {
  184. "category": "connection",
  185. "slow": False,
  186. "desc": "Max IPs per user",
  187. },
  188. # SSL/TLS ACLs
  189. "ssl_error": {
  190. "category": "ssl",
  191. "slow": False,
  192. "desc": "SSL certificate validation error",
  193. },
  194. "server_cert_fingerprint": {
  195. "category": "ssl",
  196. "slow": False,
  197. "desc": "Server cert fingerprint",
  198. },
  199. "ssl::server_name": {
  200. "category": "ssl",
  201. "slow": False,
  202. "desc": "TLS SNI server name",
  203. },
  204. "ssl::server_name_regex": {
  205. "category": "ssl",
  206. "slow": False,
  207. "desc": "TLS SNI regex match",
  208. },
  209. "connections_encrypted": {
  210. "category": "ssl",
  211. "slow": False,
  212. "desc": "All connections over TLS",
  213. },
  214. # Advanced ACLs
  215. "external": {
  216. "category": "advanced",
  217. "slow": True,
  218. "desc": "External ACL helper lookup",
  219. },
  220. "random": {
  221. "category": "advanced",
  222. "slow": False,
  223. "desc": "Random probability match",
  224. },
  225. "note": {
  226. "category": "advanced",
  227. "slow": False,
  228. "desc": "Transaction annotation",
  229. },
  230. "annotate_transaction": {
  231. "category": "advanced",
  232. "slow": False,
  233. "desc": "Add transaction annotation",
  234. },
  235. "annotate_client": {
  236. "category": "advanced",
  237. "slow": False,
  238. "desc": "Add client annotation",
  239. },
  240. "peername": {
  241. "category": "advanced",
  242. "slow": False,
  243. "desc": "Cache peer name",
  244. },
  245. "peername_regex": {
  246. "category": "advanced",
  247. "slow": False,
  248. "desc": "Cache peer name regex",
  249. },
  250. "hier_code": {
  251. "category": "advanced",
  252. "slow": False,
  253. "desc": "Squid hierarchy code",
  254. },
  255. # Group ACLs
  256. "any-of": {
  257. "category": "group",
  258. "slow": False,
  259. "desc": "Match any of the ACLs",
  260. },
  261. "all-of": {
  262. "category": "group",
  263. "slow": False,
  264. "desc": "Match all of the ACLs",
  265. },
  266. }
  267. PREDEFINED_ACLS: list[str] = [
  268. "all",
  269. "manager",
  270. "localhost",
  271. "to_localhost",
  272. "to_linklocal",
  273. "CONNECT",
  274. ]