diff --git a/.github/requirements/test.in b/.github/requirements/test.in index 3f11e92..ab6b821 100644 --- a/.github/requirements/test.in +++ b/.github/requirements/test.in @@ -2,3 +2,4 @@ pytest pytest-xdist hypothesis ruff +coverage diff --git a/.github/requirements/test.txt b/.github/requirements/test.txt index 10ae4bd..90a37da 100644 --- a/.github/requirements/test.txt +++ b/.github/requirements/test.txt @@ -2,6 +2,250 @@ colorama==0.4.6 ; sys_platform == 'win32' \ --hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \ --hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6 # via pytest +coverage==7.16.2 ; python_full_version < '3.11' \ + --hash=sha256:00d3eb96e9988c45f50cccd1f1496571ac5c1f91386ac02c4d55516eeda19a24 \ + --hash=sha256:01c6908bc613b420c26c818fe948e1b97dfd041a53c98b01c63bd8321f5c9aae \ + --hash=sha256:066429634299e14dd2d511e1e85f8f9cecc500781f6b41907c0dd6f1baea7e63 \ + --hash=sha256:0993d0e90858c03943d3cb152e068a20dd4707924deec84dd2230261baae3b1b \ + --hash=sha256:0dcbcfcc059117284c603ff8cb61a65872512882f84a8cf0339241f7f7c2f148 \ + --hash=sha256:0fd7a86fdda7cb6d616d178654bd0ad6bc0f3f33c2e478aa598500a1a9e34eda \ + --hash=sha256:11d28e9123a9156cb405d8d27b44256c9a58fb5decc2073a8f17862057e3aa0f \ + --hash=sha256:11e597173af1dc33d5f8a7332ada544199269a223af1ee1770ddd5e245ad0fe8 \ + --hash=sha256:126d1af8804d7224421fe991ff65d3ce649081560df7a98b1a5ffff07f9923bd \ + --hash=sha256:14253fc7bb15749b849795a06f5d3b6d8bc3fb8a4b5ddc341faf7a89dce205fc \ + --hash=sha256:152877cdc8a07264882cfcd503ba56a3ef6cba56a70e8c70f6eb8ffd7384789a \ + --hash=sha256:17228fbca0f22976f797be94e975dcd237799c657d49551c7de1e0654d1202e9 \ + --hash=sha256:191803c4996b499fcd78c2ad5e5f767dcc53cb4dc6de6d6a741b443a1821ef02 \ + --hash=sha256:1a37c6e478cf687e1aa30a593d19c92c02fad9d122b51ab73f51b8dc7a0c0fc9 \ + --hash=sha256:1c569a9fd25505f1cd6bea90588818f90373ce90e2632e2cacf19ddbd6e14fdb \ + --hash=sha256:1d56e4d21c56d2046447733f8b118409597db48c01efe898ee9ac24e858ec2d6 \ + --hash=sha256:1d5d0e3b660506fb84f995814e3118a21efdc0c8eb80127da1be627d90093c17 \ + --hash=sha256:1f15254427c9b33eedac4f198eaf9e356eb4f6214551afb43da6194a2c088ad7 \ + --hash=sha256:218d742afca2b5ad5ca759e93eddedfbcc6eadf8322f080dcefc40b7bd4e2d48 \ + --hash=sha256:22957cef43ce038641de78ba995de7568d2d6a37c6ddbf7fa0fd7d1ae2344d91 \ + --hash=sha256:23219888477edd736b6fcaec1272d47d93b926e999641ffea7e53a1738e70b2b \ + --hash=sha256:251aed777c47c77aba047096d4542889db089227655711dfc2b9c54ef0e15e35 \ + --hash=sha256:28ff850182a67d117990fa2ce5ea1032836d8c9630dae867e8bdd3bff4533b79 \ + --hash=sha256:29309ccc86b7f33df7db12813c299f215bbbc470ed6292d0bedd63ffae1ebf64 \ + --hash=sha256:2aca0bdfa9e91621d5b09d815357bf63def4fc0e9cb66da67bf2cf93f3b1a6f5 \ + --hash=sha256:30c1b65d529e46569899fadca59e4a87c1faf2886923f1307ba61e654d4f3c20 \ + --hash=sha256:35f37886699cb9abd29958247d718628d5bc6f39e623dff66a09e546c42a7e03 \ + --hash=sha256:382d3346d56b0eec1b793d53a4c88799c8053f516aa3a8d7c44315696954bacf \ + --hash=sha256:396bb16e04ce04efbb3df91456ae4e3da918e69ecdf67fb711b0a0fdf35ccce0 \ + --hash=sha256:3e7f99698ba3a7d13988bdd984b7ebf13af4dbe2166dc8502eef90d77603b0a4 \ + --hash=sha256:3e861f1071dcc2fec1e88bef0920f6b1eaa66a143555b4f8ab79ba2b0f30ef55 \ + --hash=sha256:3f43bac1856ba269b905302778d4df433d6006489a192174ad77ac528e395032 \ + --hash=sha256:40c0f00899fe6181ae7f434ceb200e51f5ee4b8ed10e3b5f0b605f0cae15da87 \ + --hash=sha256:414c26dfdb96aac2d570a54e03008f001e32eb2d413705365503648c6bd361d8 \ + --hash=sha256:4358b9c8c0125b460407f3017c6cce8156e904b32772c5630d27112f52bdbfe5 \ + --hash=sha256:444889f7f66b74e4455c0a97e0e166dd41177f1dca8c0239a47cff25e05ba7e1 \ + --hash=sha256:44f21e407b278efdfc1ee5e481e00518bd1d500310a30a5fbf2bcbedfef4aaf0 \ + --hash=sha256:4cc4f73aa3fabc36e32046d6cd2971405948d8a903636508a3d3b2f9128b3a95 \ + --hash=sha256:4dbbd1155ca46e6e0b6b89d204428c56ef6a459af21333f365d135a2820e5a09 \ + --hash=sha256:4ee546b9e4872ffa194bf07ac87bfa1202ebb824d0795dc1ef22f175545ca90a \ + --hash=sha256:5139009b5efd2194fc168ee9362f0e191ba612ef5d29242f9269c22f9b8f80c7 \ + --hash=sha256:5375ebd99038021b35e99dc88255022912c06565d316212f4a576e4b08d30f5d \ + --hash=sha256:5397e21a90dde0e9c6896b77ded8f0be26b66f8b22b33aed41f6043ed95d55e6 \ + --hash=sha256:57ff3783f99d75a1e81dd56a9737eb5665e6736a5d93258ba596b6dcad8fd05b \ + --hash=sha256:58d4a54c6ea672afef66d49be922a2c69826c5ae1a42a9cd94f0c9c2bacdf800 \ + --hash=sha256:59c3926585e1cd1f2190f4b2ac9014de1bbeaf0d5d0587b0dc6b0aa90d17896a \ + --hash=sha256:5a27b731c171e43dc8b5f32b76a5051dde2ec9b9366c87028f08a7088ebc2c7b \ + --hash=sha256:5b3146d2317c75f70df2509066d979dadd941f7021cdf9b5db4bcd8568258e25 \ + --hash=sha256:5dca0bb66b4c3d624ba047887bf70270030c150692d543cb501293dc38a9f4b5 \ + --hash=sha256:611a44e5229a59d7483ce830160e1a0e85f700562c7a5651c7c63fb8f4eb528c \ + --hash=sha256:648352b94507179d82637292e7ae8802508d95f78e2f00a705a50b6c48011681 \ + --hash=sha256:6a75180829efb8ae62b4aded25be6ddca1c888d138d2d82e21d93bfbd88f41cb \ + --hash=sha256:705e5af11d34647efdc170c7840b6857c81cf74be96419a553f237e68e62cb72 \ + --hash=sha256:723dcdab91357159b722935b500ee8abc0a66c8c432e1e9fabf4cc7598952de8 \ + --hash=sha256:724bd0f1e81856b35e59fc98cf7b4e544a3cb662e4e0864dca73d4326ee9d808 \ + --hash=sha256:732d950e51f3ba4fb6209c73250f3e8924fefca42953ee04a9e65d8c02414d7d \ + --hash=sha256:736fde09ea39646d11f8e3b76bd3425c075aa4dd45f24891970bb77c14ff20f5 \ + --hash=sha256:7a076277ca9f5750cc230f0f578ebd2620cec60255b25707361699fef6fb465c \ + --hash=sha256:7b3bce4a0d05401d70b7d0d5ca783e686bc9d30e81dbd7d980d532609bf809e4 \ + --hash=sha256:7b451c68218c150f616bc9649783ec8de76a59792c759b43aa0c9c0466a465e4 \ + --hash=sha256:7d0732c83746bc24123c581a85d9dd96b70ddb538c9076020aa1a041790361e9 \ + --hash=sha256:7ed238d227e23cc300c3d464babdaf9f6ddc740aa1b15a77ae96136e6a7c4516 \ + --hash=sha256:80d3f7b48d43ee8fc5e8707a8adb43d743a5a1a85256c25a24f9d6d0e2238fa6 \ + --hash=sha256:80e9fdb4c3d926b6ba721d4bf7435bdb869c3527ae7803290361d0ab73db13b6 \ + --hash=sha256:848893e1d361448c113dc2f0913503522a6f7be231d0e38333d2a22d9698a011 \ + --hash=sha256:893ea9cf86cb8d2546812ac93d973aaf2ee1fb45110a873b014214fd23e3725e \ + --hash=sha256:8afd9bf35cc6a1f22eb3634808fa8e0b91902459c5721ef2e4461dfe771d7f08 \ + --hash=sha256:8be099e979fc42559328a21828281b4578304191ae46ed4e80a407048a82eee6 \ + --hash=sha256:8e209591f7c41ae4a9171335cf6156afda0b21de73b02f73f5aa95b2d5fbb08d \ + --hash=sha256:8fc15cc8d0d06e873c00ef18e1372d605f9aaf3de27d8c24e50782e75bc8b843 \ + --hash=sha256:9174f0af24e5eff248b9dbfe76ec5275a3d19d37edbc2810543f12cf97347a34 \ + --hash=sha256:921415102a90637fcc2e3f169f61dad7699ecf690e8639fc21b813acbedc0967 \ + --hash=sha256:967d72c835d7a8cf0af99ec813a2d06e3db6df706402f1fe85b31b437645f495 \ + --hash=sha256:98d9c97f51b334b0adce7b964442a9af33c1a00c6ac856984cc5dc8d18f81c75 \ + --hash=sha256:99704f73721e23859112072d522076e11c31744fc96b5652e5dd2018aa4359f7 \ + --hash=sha256:9a75a4704ff640e46170042eec1f984385a121227c505d5a16ad8e495f452541 \ + --hash=sha256:9acc7f7ec4a1b5f89bd929fde5b8a714f6fafdc6cc18725413d510aa082b47ad \ + --hash=sha256:9c6afdd69218202bc1758c9a14b86b8cf1084f37ed2ca143e567a103772b16d1 \ + --hash=sha256:9cdf19874e0d247f32f03609200370343c3c7aa260b191d8c2bb251d36198283 \ + --hash=sha256:9e1d0ced76318bab499693ff25f64faa343415187cb2e4d7befdfdd391a1cf6a \ + --hash=sha256:9fd670ac43b709c575aefc25bf52d8a598a3bc5017bddfd0a179152ab06a2deb \ + --hash=sha256:a0f2285329dac10ab08f79cb11f5692c497018e6c7c511f95e6fd63a70b8f831 \ + --hash=sha256:a2fac6895eb299a2e52d7bbb8fb3903502b9da8d3f5309ceb16ec40c646b58ee \ + --hash=sha256:a336eec40e3520d369b8a6cdabb4f596e69a8b42927ca074aa1452fed943238a \ + --hash=sha256:a4624f80732f6b427ac58f1f59c577a0994a12e8174b5af6a027b4b58795d4c3 \ + --hash=sha256:a56ac4fa5a75c7e182e8f62600cfb4aff43c5ed7356a034f3557659c3bec1d90 \ + --hash=sha256:a678c0b6b22086ec2427359d22e37445d4a792f5fdbbc744112c7dade65cad02 \ + --hash=sha256:a740ea6f083c6db7b926534d159508f80ba275ab35e722522de0d18d0f56e55f \ + --hash=sha256:a90700f743e29aa3d75a6ff5f01953176a889c00e526194bc4d281731b88d99d \ + --hash=sha256:a9a638be322a8d76a41cdb17781c7f82aaee6a66493d8ffb7e2c09ee22423d99 \ + --hash=sha256:a9cd3de0a5bfe7b0e21ee10e1a14e3d61bf52efc88217ab1d95d6ace6970bd46 \ + --hash=sha256:aa62c85046473959c13ba9edca9dc90a77d5c1095b1ba313556314d77fe5b036 \ + --hash=sha256:aba5c63b7afdc749cc9eae943d5b868cba2b261a176378fa1c5a30bc8bc89982 \ + --hash=sha256:ac0f3b379c94acc2f7dce5f5f0b24d44fa1cc6a509717ef83dfee07450c2117c \ + --hash=sha256:af2a2a8c7c74de0559e0c368d94c8def9e16c58faaee33a0bf081057c4227e3b \ + --hash=sha256:af98ad5ed9d6daaca956201e00bb429a7eb2b080426686f70a20353e0f9839f5 \ + --hash=sha256:afdf43b72ef3876c1fe66423b91466e37877c9e81e8cec70542b7e8525b9d1b7 \ + --hash=sha256:b88841e654f09732804809e435b3e005a929ffd9998b872b7b213957b8759cb8 \ + --hash=sha256:bb2fc905bbf4e6b7f40806ea79e31515abf6349594cdf0adf27c4215f0463204 \ + --hash=sha256:bb4ffe96aa663cee727659db5a2afeb38c95f8677b747d447b90d6d4874ea2c5 \ + --hash=sha256:bc0b0ac781d489304b741269857f1f8338b7a26b1b89c06c0344658001ec0035 \ + --hash=sha256:bf1bd822ec4e387ed245bed0d71151582cf7be9e5309bc4145eefe36083d5878 \ + --hash=sha256:c19cd6d025c1673f22afcd22c7df8a662d779e05d8e3fa6820c22afb895b0206 \ + --hash=sha256:c3305c38a2fa21a4254f2ace7dd9ef5fc569c9a558b66e7017650b3d637fb95e \ + --hash=sha256:c85d54e7e8a2ca932fe8399301af9b8d5907ea2a455ffaff6e7d1208db83b943 \ + --hash=sha256:ca64d9f1f384f151b9511bec01126072acd2f313439f8ed015a22d8790aab6fa \ + --hash=sha256:cce2bc991293f15cc4084ca116827b5900c5f34e1a54dfe83f10ab5c43162eb7 \ + --hash=sha256:d6276d78f6fca7d0ac066d5da4165c5acd07829e8305c2cb900b738fb3a75a72 \ + --hash=sha256:d93db87adb6b1c1b408dce4763314b55d76a9f589e96783a84ac9e7689e48bdf \ + --hash=sha256:db5f8394e17f877a625b257f2ba0ce8e728a499c2c1579ad66220272cd3df510 \ + --hash=sha256:db76506aa5416081f3e8974ae0f7965c58ada0bb0ef7339ac86099588dbb20d3 \ + --hash=sha256:dba2edfb054f6d4a08df9d1637c39a5aa3865bca6617c13c86be21e45658a59c \ + --hash=sha256:dcf4bc2aab4e16b1c4c0c2005918f23a7dd5d7821ddae82caed9e3342dc2fcce \ + --hash=sha256:e1fa594c887365b69745f25a416806e61085dd07b94c9eae68a6e20730629b23 \ + --hash=sha256:e6c52d3307824ff93b39efd99e4185d557db40bd841452abfb32e5d9151ca162 \ + --hash=sha256:eb57acff4a74246ae513c142d4b36e18c389c3aed8661914a53f7cd0071031b2 \ + --hash=sha256:f80bd9f9633eafc73d0a913ba2645c96ba58bba1befc30590f7c0fbfde59d865 \ + --hash=sha256:f8475460aa33ee28ac896ab1156d0bb3b6c639f7f8383c2677d3359eb35f8205 \ + --hash=sha256:fb2bde05838fffae1a1bf75e5d411a6cac3e4e9bb97e6640fed8cd47888b33f0 \ + --hash=sha256:fb9d92ecfe2d5b494367c67f7446f8b75b68d8d0c8cf3bc3e6997478be25d9e2 \ + --hash=sha256:fd3d72233eb8b48acc94fa57d44e2d32ce8e7abed02882ccb6d855ccc4ed33ec + # via -r .github/requirements/test.in +coverage==7.18.0 ; python_full_version >= '3.11' \ + --hash=sha256:019291ddc4e663c4e3c9ca2e93b4928333d117019c9760b827b287dd8f88e1c2 \ + --hash=sha256:041b7da73462294b32e63d85556a58f28465e3b5b368069553d3e4f5414852e6 \ + --hash=sha256:04551c389f9941280d58ca7b43fb81c9be68e50e91d6fe020ec0196a69b82b4e \ + --hash=sha256:06a9051f33f4cf66f7ef1764ec080ab15b6ecbbfcaf02acadc92d92daac7d796 \ + --hash=sha256:0b1a94f1d4015a3e566c815cb1bfd25be6a7a5a07ec7e3fc7dd97e1ab8bbac4a \ + --hash=sha256:14574d625824113d0447912fe0b67ac98f89c2fbd53e4216d00f832b76b05bd6 \ + --hash=sha256:186da9badea00c533b5442eedd817f58dbd788ca1828209c8aece222f2184dc0 \ + --hash=sha256:18f9e6d346c55eaff13c1ba0c1d0326dfc9db68d3311e8e34ce93ebb57e48d7c \ + --hash=sha256:19aa1b39a7d428bc8cab0e5bb5a92bd6c016b924b56c9a85b01c8c2f45324db3 \ + --hash=sha256:1b7aee404e53abeab4dd6985556d5f87a229e8c372dd4fd52704e9f70898317c \ + --hash=sha256:1db58dff2e82d1a9ad588570e7c57867d618a2ebb688241fea98d67fb59224f8 \ + --hash=sha256:21df0391e721d8788466d83bf231850f4a4c49ddc9a6a77759667389937ffdf2 \ + --hash=sha256:23370fcef3c15189a7b5a972d7a6f71afd3395750ae19dd26ea4fe78ec53c61d \ + --hash=sha256:26996b004aa04573ed8c2db6e440860de319a9f6253498fbc5cc960fb6153853 \ + --hash=sha256:26af02eb583c0ad1156f9ae4165c83070ff6931530cec800a011be8270489c79 \ + --hash=sha256:290dd85ee7e43a99a110c8e7506eb8f6943b651fb56f02600ba67a4c2f96be53 \ + --hash=sha256:2aee866f8a232d4378f533f5635251678b479b670994b48d61360842d9023cab \ + --hash=sha256:2bb2c054130632f2688f8543d1e5d441735e59503bfde2b4161b368583f7702a \ + --hash=sha256:2c584b32f9e7cffd87ce0939e1637f36a3bf0a30e3c8c52f665efdf1c0b34b1e \ + --hash=sha256:2d8676820aeac97239e08227a284c6562dbd35db6dd7e982ef8bf9f4e32f9229 \ + --hash=sha256:2da02772eae0d083f07d621e8206260138beefaddf3c85edf216abcd4342e455 \ + --hash=sha256:2f35c2418de025bad5c2a1fdc9481198115bd10582e82f9ce2115e99291fb5a2 \ + --hash=sha256:2fbaabe5efa61a5d44145d7b37764e9f073723d0645a374826458d1f795b3661 \ + --hash=sha256:304971d13d32d460eae3a48e66de8f6bd087a887e7e3772ebf892c661825be6b \ + --hash=sha256:3346e60d6230829db2e6b2a8c199d6aa6efd864a095d3717a740dc0f6a6fd6b1 \ + --hash=sha256:345b0afbeb6ae1925422592e420c7288584f1cdddefa602527f856c421ecde04 \ + --hash=sha256:37bf304bd3ff00d6f28156152b35e7285e4de3b6f163ada9be7bdee9f496aec6 \ + --hash=sha256:38297b0de0c445856bfc11a704ff240198585aaa03d8c7bfa9f0a69433abbe88 \ + --hash=sha256:3b2ebbcaa57828ae51d08d3b07541a1eaee6b3538405dfd6e00566ba5fd305be \ + --hash=sha256:410a5327098c8c6a96c7af17cdc703df019de5c56855b7a45829dbbdf4b8f582 \ + --hash=sha256:425f0b8fa746ecaf110ed3f831295feaf67d6ee539b9887d17c07504d0d464e8 \ + --hash=sha256:43689bb7c4d8ab3a54ba1d923bd9282e50604e8691be9dc0484b47af16e58686 \ + --hash=sha256:4552d064c6779d14705518193da97fc9b373d2ac1713ec463dfc38c95f4e81ad \ + --hash=sha256:47d1d451e107f836bae9d39bcf8e45cb0bf576d9a5cec8064518e48c6aeb3391 \ + --hash=sha256:487033703c29cdaa3618e1e8d2442317c0045b8c8d18be34acc6d60106ca9268 \ + --hash=sha256:4c057e15c980989c8602aff25dbf02f632fa60fae28cef3564e689d135dd2ebd \ + --hash=sha256:4fcc541be778613d134caf9fabb2f6c7b39204e880f7b3d6d8a17461cb5d3849 \ + --hash=sha256:5106a4dd74d92f94a99c61c86ff3f13eed6cd2fab7e112e9b5f3d38e430e91f7 \ + --hash=sha256:511edacf9589f9df6dfe82bafa270bca89380da897bf4d431e27007b29b4c0dc \ + --hash=sha256:5188bcd8c4bd257696d937f3b7926f644549fd49dba62bbf8c867b122162760a \ + --hash=sha256:53f00c1d9fee5218ae770fc003b8ae6233c2ca6962a4411312383cd6ccc01ea3 \ + --hash=sha256:5731cd3bc436802fd8ebec2913eef852c90e2ed1556684cfbb3665ea932312b8 \ + --hash=sha256:57b9a3dbaf80c7d55ee42f56020bec896b2c7ce320bca5a27f339956bf2564a6 \ + --hash=sha256:58ddff21a6a4e9aef487c5cc72124b1a2c75452df9b23075934a02580f28e06c \ + --hash=sha256:5cdaf8f88abeeb4675055aa33eba6e982b9f5a803556deb198e8e22a3dfb8087 \ + --hash=sha256:5e1b10461c0e9029b3c4d53abfc0794deda32500607f2238d798a0255be14444 \ + --hash=sha256:5e859cd08cbbcfca8a94a471a7ee52c238e2c497923e98ad6da816a615bff904 \ + --hash=sha256:5fe7960d3b39675efea1272b10cc3988a7b307c5bf75367bf5d9ff9637a5f28a \ + --hash=sha256:61a01578d43e3bc88b9686cf736ea9127430db5a6060b3b45858c1eef3455128 \ + --hash=sha256:65e88bd482732ae640b324898afb82a28432859d2d1548fa2ebd2a8e6c0a4a30 \ + --hash=sha256:6b37f74ab85356ead041f036c1607f09cc00ef34ef3c21b0e4144476414a7c64 \ + --hash=sha256:6f7cfb050bb23f64113178776918024c8d0a2f7f54cd9b700e9903bece84e898 \ + --hash=sha256:7252429bd59b0da6e7f4bb0d0a407eea9e526d358b72feb5a39e0d79ae5f29b3 \ + --hash=sha256:738f79c92c5f49808d89983fd110c51d5ef14a0dee2530030550e073a41705c8 \ + --hash=sha256:73c9b20f8e4df974260f150c5e4aefad62f1fac9d78bed38592ed2681b885910 \ + --hash=sha256:7577a67a99b049c75159de953661d939b94beb70eb4b2184523ce4919bb8a567 \ + --hash=sha256:760fe2423a55d0307efbd990c978ea2e75a4777dca8217e9fa2f886265f29bdb \ + --hash=sha256:78acddd1aed34874013c9071384616f890c73a2c586d5fca738e94c49e2afb14 \ + --hash=sha256:798fe514dc1c7f5b4f1ae2de844fe9d67b302331ee32b47337de811a174715a3 \ + --hash=sha256:7a90f20668cc0a1aedef26d366a0116fed09cb60efcfd4c48effb0f80637cff6 \ + --hash=sha256:7bb6963bdbe18d8d2786dac131c83a704b7c6a1768ff520d25b0bb5d3189918c \ + --hash=sha256:7d07c2f9aa5dabe9220a78e50cfc6e38abc23c4273cfa5d0b40b9e3fc06f3451 \ + --hash=sha256:7d25a73b2ae9f353f78dbb50295688a70c7c0b82b225d80210a99ea986c9d352 \ + --hash=sha256:7d891f7e3b5f4f698cdcf9faba0c1a8aa546ab0c50cf0eecbe286cabe23e16f8 \ + --hash=sha256:80d6d63a0a8f0f19b6af7fcd6be4b086bb6fb945c35ecc8e89363f145cee01d2 \ + --hash=sha256:8369e55eaf84968595bf12257bfe577a10ddc52749d4ce885da14a0b0c70dfaa \ + --hash=sha256:85930db02b6a00aaf15cb5ba2ac4b58beeeb78a1a639ca98d11ae1cff071078e \ + --hash=sha256:87d3f47400b417932abc384b4f9bc3de6e3f2850676efad14d9b634f25d1c5d1 \ + --hash=sha256:8fff70fbec357e1d392568772b4a242cc7dc54d76d30915090ebf8919e73a5fc \ + --hash=sha256:901fe85f528b9054e6aa80e4d05662e9223a95f19406c4a53e56dd12849b57b2 \ + --hash=sha256:906976f9915913302d207d6788c83bffcb05307806fc910e6c7eb4f842a225b4 \ + --hash=sha256:941f02f81d96c5cc7bf501e682d1914b7d99edb07795534181dca89a6646d8c7 \ + --hash=sha256:950ecfce98dfece283e1477908911f10f91c8cfdb0e7d31d009d9f27ffe0f4ed \ + --hash=sha256:971b8eea5046be5707d287977f3cff5c7d8143029a0e0e631af3075f0effa65f \ + --hash=sha256:97761b08a88c99365e7b8f4df487b1476c71c03f441a699009daeb42628ee5b2 \ + --hash=sha256:978156935e95ad1bd421925a8cbf8dd2f7ca3f960e27bf79fdcff8f27d55c655 \ + --hash=sha256:9a63d93b51d8c9b39c202a6a6efe783cbc44264191471e02a50f1a978fbe9cc4 \ + --hash=sha256:9d4881f069484ec0de1696ba4f1a66ea04faff948b8aa8a1172462a319111f37 \ + --hash=sha256:9d6bcde38a2748b492df0592e87a15fa5e649a2366218740a43ac42ba4c4ac00 \ + --hash=sha256:9df6c16283323cc1f141773bf89a3f2466156db1ccce19ff885a41b5a47037de \ + --hash=sha256:a228e48ba4ae337846f321702939ea3e74025e3b3cbb20c8ef920f2f8a73cc71 \ + --hash=sha256:a28e71a2bc34bef6ae8e0bb03425cc8be334fc47ca564c1818947299f806f1c3 \ + --hash=sha256:a29b2a1141aa6a6c6bb373014d93680776afa718bcfb60247e5b36b4d4e5fb2e \ + --hash=sha256:a610b3c9680dd04afdcce900e76407c6ff876f3cdfb0e2fe20d946c28ff794dc \ + --hash=sha256:a776021fbd363521ea5f74967e0f01f3af43b194d96f05eb1dd6c9b01eebf4dd \ + --hash=sha256:a7b56b62e0dcb0932e1c8935dd8ab8ea608d9c3e341c79ca42338b423cf2ba3f \ + --hash=sha256:a989777145597f07f5db8c2e8768e3638f3a8049bcfeeb56f61fd70ccfdd8655 \ + --hash=sha256:acaba0e9d5dae44236ec929d295137036ec6caa43d4dc805928b8d7e0995c9b6 \ + --hash=sha256:ae11683de228222196da81936450c109e9575fec48ed5658ff0fd6f47a7bc40a \ + --hash=sha256:b4f867fe47373534b6caed43cbe3882a0f14766aa272e448a1cfc78595538185 \ + --hash=sha256:b61fe81af35aad950288659937d23bcabe33800bb2a7da2b98d714bb24e244a9 \ + --hash=sha256:bbbce08e600454d5f53bb3698711d764ca699fb715be548dac9f40ff3b2420ab \ + --hash=sha256:bf7c3853c43eae22049fe5d5f49cc8613dfc763035afbf9aadcde7c32dc1c554 \ + --hash=sha256:c5db509ec59c974654c7e1e6491094074b307ec348e5ebf0848265bcc864756b \ + --hash=sha256:c81ae6c62807cca4aa5df15912f77c2c35584ed5f2b0273953f99789a98d6247 \ + --hash=sha256:cb93ebd8505845ff3dccfc8f4224e92494bd66e4cb6630c49c29a0c4753d1a65 \ + --hash=sha256:cc7bbd5784fb9590958a51b0cd0a562209151514700d322294550a86753b6f68 \ + --hash=sha256:cfb497d3fa36b4e47a3a549d7e62caf617d7caded5c969058c6898c9e615c5f0 \ + --hash=sha256:d17fd0c367201117165d1f8919b44be3830040da05f7b2ae8c8205514216a29e \ + --hash=sha256:d1a1a25e4b1090df14e09d75f6d9d72540533861ddc1c42e496aa00a92a49155 \ + --hash=sha256:d302b62af4b90a0242b705c6c8cb3fa6d56c16917efc8931942cd80ab7af9f42 \ + --hash=sha256:dc04ce588a8e277b5c10033ff870736424ae6ef84594efa6ee67116c1411e5a6 \ + --hash=sha256:dd7258fab7dbc3bedcc94d6e9d4431408e390f080687b3463dbee3147715867f \ + --hash=sha256:df7e6a9aea715fe265c34a16215ca5687f4ea9be6f60ff0466e92dcba0b9d42b \ + --hash=sha256:e138c8bad1cb41e473616af1aec9f0af2c577eb5545c61c5316c3a7f8c16f7cc \ + --hash=sha256:e36cbf67badda80444ed4ebb37cc3408ed9ea2841afe7673abb39eb99ca5955a \ + --hash=sha256:e6437adddfdf5a9661b3f841fb37d548fa0a65c4d31c58b1f642d2b5d05bd62d \ + --hash=sha256:e7fc6ceb1d818c81246ef0885f5bf27b0eb9086a03ef1dfa709500a8311ebf2a \ + --hash=sha256:e8319b9c65a5a2b0f0f84c062d1181d9335d5cc62e7e3a0206c7540ec65dba8b \ + --hash=sha256:e9cf9e831e7d7245a6788889baa36b3480fd254adb434bb7ce1c40a419237c58 \ + --hash=sha256:ed7bcaec8d49ac2a81fb38f007416a6eadb911b93132cd5bc3060c1aa4d6ee3b \ + --hash=sha256:ee99c0421e1fd46082ea1331b0ac2953fc0503651b49f4c012623023ba046fe4 \ + --hash=sha256:efeadfafa2b6387035dd3b7f091cc92eef42ad1be9e3736c3c50e2189ea3661d \ + --hash=sha256:f3ceab01a6d5626aa305eb0c8237b62d6a6e42913105eb11edb57523c1f032c6 \ + --hash=sha256:f6643a015a3a78c6a0f8f46e2e5bab123587fd0f46273a74864dcf4168f52e07 \ + --hash=sha256:fad89bdc436ac0f9735d4c48e20955d66e24d1d5b059ef542d94ff639db657e3 \ + --hash=sha256:fc467f7c53eff1963f8cc42141786a4bbabcbe9c0cd7ebd1437e6002f15e9cda \ + --hash=sha256:fd52df836d1e645e5ec32739c95daa4bfae697d2b3e84dea10918023c8891a40 \ + --hash=sha256:fef0517d326cc1010b5999af6d4940fc47b3d6e67fc8e4ff3b1430ba2f0cd312 + # via -r .github/requirements/test.in exceptiongroup==1.3.2 ; python_full_version < '3.11' \ --hash=sha256:41c6a70dfec22050d3d8b43386b059a4dc0bca3f3d40a40971cb206fff1785af \ --hash=sha256:ca82e69f0cb535fbde934885744b67669a3efddd50fe7bc00d3398839fcaddec diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 5a546ec..1f35873 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -1,15 +1,17 @@ name: fuzz -# Atheris (tests/fuzz_atheris.py), a coverage-guided fuzzer, throws random commands at the paid step's command -# filter (bite.command_ok) and keeps the ones that reach new code. A crash, or a command it lets through that has a -# redirect, a secret file name or a dangerous word outside quotes, is a find. 10 minutes weekly, 1 minute on pull -# requests that touch the filter. A find fails the run, which emails the maintainer. It opens no public issue on -# purpose: a way past the filter is a security hole, and SECURITY.md asks for those to stay private until fixed. +# Atheris (tests/fuzz_atheris.py), a coverage-guided fuzzer, attacks Bite's three security lines and keeps the +# inputs that reach new code: the paid step's command filter (bite.command_ok), the worker's file access +# (bite.edit_ok, bite.read_ok) and the rerun command built from test output (recent.only_these). A crash, a command +# with a redirect, a secret file name or a dangerous word outside quotes, a file outside the project copy, or a +# rerun name the shell would expand is a find. 10 minutes weekly, 1 minute on pull requests that touch that code. +# A find fails the run, which emails the maintainer. It opens no public issue on purpose: a way past these lines is +# a security hole, and SECURITY.md asks for those to stay private until fixed. on: schedule: - cron: "29 6 * * 3" # Wednesdays 06:29 UTC pull_request: - paths: ["bite.py", "tests/fuzz_atheris.py", "tests/fuzz_oracle.py", ".github/requirements/atheris.txt", ".github/workflows/fuzz.yml"] + paths: ["bite.py", "recent.py", "tests/fuzz_atheris.py", "tests/fuzz_oracle.py", ".github/requirements/atheris.txt", ".github/workflows/fuzz.yml"] workflow_dispatch: permissions: {} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 25d8aa7..ed6a31c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -60,4 +60,16 @@ jobs: - if: matrix.os == 'ubuntu-latest' && matrix.python == '3.13' run: ruff check . # 4 at a time (pytest-xdist): about 4x faster, most of all on Windows, where each test starts slower (#16). - - run: python -m pytest -v -n auto --dist worksteal --durations=20 --part ${{ matrix.part }}/${{ matrix.os == 'ubuntu-latest' && 1 || 2 }} + - if: ${{ !(matrix.os == 'ubuntu-latest' && matrix.python == '3.13') }} + run: python -m pytest -v -n auto --dist worksteal --durations=20 --part ${{ matrix.part }}/${{ matrix.os == 'ubuntu-latest' && 1 || 2 }} + # One job also measures how much of Bite's code the tests run (statement coverage, counting the Bite runs the + # tests start in subprocesses), prints it, and fails under 80% (OpenSSF Best Practices Silver asks for 80%). + - if: matrix.os == 'ubuntu-latest' && matrix.python == '3.13' + env: + COVERAGE_ROOT: ${{ github.workspace }} + run: | + python -m coverage run -m pytest -v -n auto --dist worksteal --durations=20 + python -m coverage combine -q + python -m coverage report --skip-covered + python -m coverage report --format=markdown >> "$GITHUB_STEP_SUMMARY" + diff --git a/.gitignore b/.gitignore index 602ef7a..8c0f330 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ slow-unit-* timeout-* oom-* leak-* +.coverage +.coverage.* diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 32da458..454defb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -65,6 +65,8 @@ left unchecked. The one real ask: - **For a bug fix, a test that fails without your change.** That's Bite's whole point, so we hold ourselves to it too. Not sure your test catches it? Run `bite live` before you commit: it tells you whether any test notices your change. +- **For a new feature, tests for it** (a new command, option, language or message): added to `tests/` in the same + PR. CI also fails if the tests cover less than 80% of Bite's code. - `python -m pytest` passes, and CI is green (those checks do block the merge). - One fix per PR, with plain words in the description: what was wrong, what you changed, how you checked. - A short title in the [Conventional Commit](https://www.conventionalcommits.org/) style, like @@ -75,6 +77,17 @@ Nice to have, never required: light and dark screenshots if it changes how somet If a small piece is left over, a maintainer may finish it for you and keep you as co-author. Once it's merged, you're credited by name in [CONTRIBUTORS.md](CONTRIBUTORS.md) and in the next release's notes. +## Code style + +- Python follows [PEP 8](https://peps.python.org/pep-0008/) naming and layout, with lines kept near 120 + characters. The rules we enforce are ruff's (`[tool.ruff]` in pyproject.toml): `ruff check .` must pass, and CI + runs it. It catches unused and undefined names and syntax Python 3.10 can't read. +- Standard library only: Bite has no runtime dependencies, so don't add one. +- Use `pathlib` for paths and open text files with `encoding="utf-8"` (CI runs on Windows too). +- Messages users read are plain words, in US English (a test checks the spelling). +- How the code fits together: [docs/architecture.md](docs/architecture.md). Who decides what: + [GOVERNANCE.md](GOVERNANCE.md). What's planned: [ROADMAP.md](ROADMAP.md). + ## Where things are | | | diff --git a/GOVERNANCE.md b/GOVERNANCE.md new file mode 100644 index 0000000..af9d614 --- /dev/null +++ b/GOVERNANCE.md @@ -0,0 +1,43 @@ +# How Bite is run + +Bite is a small project with one maintainer. This page says who decides what, who does which job, and what +happens if the maintainer can't go on. + +## Roles + +| Role | Who | What they do | +|---|---|---| +| Maintainer | [@connabyss](https://github.com/connabyss) (CH) | Decides what goes in, reviews and merges pull requests, plans and publishes releases, answers security reports, owns the repo, the PyPI project and the MCP Registry name. | +| Contributors | anyone ([CONTRIBUTORS.md](CONTRIBUTORS.md)) | Open issues and pull requests. Follow [CONTRIBUTING.md](CONTRIBUTING.md) and the [code of conduct](CODE_OF_CONDUCT.md). | +| AI helpers | Claude sessions the maintainer runs | Write code, review and fix bot comments, and squash-merge pull requests only under the written rules in [CLAUDE.md](CLAUDE.md) (every check green, every bot comment handled, on the exact commit merged). They never publish a release, change who can see the repo, or merge changes to CLAUDE.md, AGENTS.md or `.github/` from outside contributors without the maintainer's own OK. | +| Review bots | CodeRabbit, CodeQL, OpenSSF Scorecard, Bite's own check | Comment on pull requests and scan the code. They advise; they never merge. | +| Security contact | the maintainer | Reads private reports from the [Security tab](https://github.com/connabyss/bite/security/advisories/new) or connabyss.code@proton.me, as [SECURITY.md](SECURITY.md) describes. | + +## How decisions are made + +- **Day to day:** a pull request goes in when its checks are green, its review comments are handled, and the + maintainer (or an AI helper under the CLAUDE.md rules) merges it. [CONTRIBUTING.md](CONTRIBUTING.md#how-we-review) + says how reviews work, so a contributor never has to guess when they're done. +- **Bigger changes** (a new language, a new command, a change to what Bite promises) start as an issue, so anyone + can weigh in before code is written. The maintainer makes the final call and says why on the issue. +- **Releases** are planned by the maintainer. A release is a pull request that bumps the version and adds its + CHANGELOG section; merging it and publishing the GitHub release puts it on PyPI. Nobody else publishes one. +- **Security fixes** follow [SECURITY.md](SECURITY.md): fixed in private first when the report came in + privately, then released and credited. +- **Disagreements:** say so on the issue or pull request. The maintainer decides, and a decision can always be + reopened with new facts. + +## If the maintainer can't go on + +Bite is MIT-licensed, so anyone may fork it and carry on under a new name at any time. + +What keeps the project itself going: + +- **Releases need no secret key.** PyPI publishing uses Trusted Publishing from this repo's `publish.yml`, and + release signatures are made by Sigstore at publish time. Whoever controls the GitHub repo can release. +- **Everything else lives on GitHub:** code, issues, CI, the Action and the bots. + +**Open gap, said plainly:** today Bite has one maintainer (a bus factor of 1), and no second person has been +named who could take over the repo and the PyPI project within a week. Until that changes, Bite doesn't meet +the OpenSSF Silver "access continuity" rule. Want to help maintain Bite? Say so in +[an issue](https://github.com/connabyss/bite/issues/new). diff --git a/ROADMAP.md b/ROADMAP.md new file mode 100644 index 0000000..e8001cc --- /dev/null +++ b/ROADMAP.md @@ -0,0 +1,39 @@ +# Roadmap + +What Bite plans to do, and not do, through the end of 2027. It's a plan, not a promise of dates: the +[issues](https://github.com/connabyss/bite/issues) show what's moving now, and anyone can pick one up. + +## What stays the same + +Bite does one job: it checks whether the "fixed" in recent commits is true, by taking each change back out and +running the project's own tests. The free check needs no key, no account and no network beyond what the +project's tests use. + +## Plans for the next year + +- **More languages.** Ruby ([#86](https://github.com/connabyss/bite/issues/86)), PHP + ([#184](https://github.com/connabyss/bite/issues/184)) and Deno + ([#277](https://github.com/connabyss/bite/issues/277)), and monorepos with several test commands + ([#187](https://github.com/connabyss/bite/issues/187)). +- **Check earlier.** A pre-commit hook ([#87](https://github.com/connabyss/bite/issues/87)), and `bite live` and + `bite mcp` tested end to end in more coding AIs ([#186](https://github.com/connabyss/bite/issues/186), + [#276](https://github.com/connabyss/bite/issues/276)). +- **Fewer wrong flags.** Every false alarm someone reports or a [Fool Bite](https://github.com/connabyss/bite/issues/156) + entry finds becomes a test, so it can't come back. +- **Easier first run.** Every place a new user gets stuck ([#185](https://github.com/connabyss/bite/issues/185), + [#246](https://github.com/connabyss/bite/issues/246)) gets fixed or explained. +- **Security.** Keep the fuzzer, CodeQL and Scorecard running, reach the OpenSSF Best Practices Silver badge, + and close the gaps [GOVERNANCE.md](GOVERNANCE.md) names (a second maintainer). +- **More READMEs in more languages** ([#253](https://github.com/connabyss/bite/issues/253)). + +## What Bite won't do + +- **Fix your code for you.** Bite reports, and at most writes a missing test you choose to add. It never edits + your project's code. +- **Use your Claude login or plan.** The paid step uses an Anthropic API key only (see AGENTS.md), and that + won't change. +- **Phone home.** No telemetry, no accounts, no hosted service that sees your code. Besides what you ask for + (cloning a link you give it, the paid step's API calls, git-lfs fetching your project's own files), the only + network call Bite makes is the version check against PyPI. +- **Grade coding AIs against each other.** Bite checks claims in one project; it isn't a leaderboard. +- **Promise a commit has no other bugs.** It tests what a commit claimed, nothing more. diff --git a/SECURITY.md b/SECURITY.md index 198ce16..e8eaf3d 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -12,6 +12,35 @@ security hole in Bite matters. Please tell us about one privately first, not in Say what you did, what happened, and which Bite version (`bite --version`). A small repo or command that shows it helps most. You'll get an answer within a week, and credit in the release notes if you'd like it. +## What happens after you report + +1. **Within a week:** we answer, say whether we could reproduce it, and keep talking in the private advisory (or + by email). +2. **Fix in private:** the fix and a test that fails without it are made in the advisory's private fork when the + report came in privately. The Atheris fuzzer (`tests/fuzz_atheris.py`) gets a case for it when it fits. +3. **Release:** a new version goes to PyPI, and the CHANGELOG says what was fixed and who to thank (unless you'd + rather stay anonymous). +4. **Publish:** the advisory is made public once the release is out, with a CVE when GitHub assigns one. + +What Bite promises about security, its threat model and why we think it holds: +[docs/security-design.md](docs/security-design.md). + +## Check a release + +Every release on PyPI is signed when it's published: PyPI's Trusted Publishing has this repo's `publish.yml` +make a Sigstore attestation for each file, so there is no private signing key to steal. PyPI shows it under +"Provenance" on each file's page. To check a file you downloaded: + +``` +python -m pip install pypi-attestations +python -m pypi_attestations verify pypi --repository https://github.com/connabyss/bite bite_check-1.0.11-py3-none-any.whl +``` + +Pass the path of your own file (here, a wheel in the current folder): a file changed after it was published +fails. Writing `pypi:bite_check-1.0.11-py3-none-any.whl` instead checks the copy on PyPI without a download. What +a pass proves: the file is the one published to PyPI by a GitHub Actions run in connabyss/bite. It doesn't prove +which workflow in the repo built it, or that the code in it is free of bugs. + ## Which versions get fixes Only the newest release on [PyPI](https://pypi.org/project/bite-check/). Update with diff --git a/docs/architecture.md b/docs/architecture.md new file mode 100644 index 0000000..55a6250 --- /dev/null +++ b/docs/architecture.md @@ -0,0 +1,71 @@ +# How Bite is built + +A map of Bite's code for people who want to change it. What each file is for is also in the table in +[CONTRIBUTING.md](../CONTRIBUTING.md#where-things-are); this page shows how the pieces work together. The +security side of the same design is in [security-design.md](security-design.md). + +## The big picture + +Bite is plain Python (3.10+) with no runtime dependencies. Its own steps never edit your project's code or git +history: tests run on throwaway copies. It writes its output in your project's `bite_proof/` folder, and a +JavaScript project's `node_modules/` is linked into each copy rather than copied. The tests themselves are your +project's code and run with your user's rights. Details: [security-design.md](security-design.md). + +``` + you, a coding AI, or the GitHub Action + | + bite / bite ask / bite live / bite mcp / python -m bite_check + | + recent.py --- finds fix claims, runs the free check, writes the report + / | \ + repo.py bite.py (paid step) Claude Agent SDK worker + git, settings engine: writes one test of a claim, + copies, test runs, inside a copy, behind + command filter bite.py's permission check + | + your project's own test command + (optionally inside contain_command, for example Docker, no network) +``` + +## One run of the free check (`bite --free`) + +1. **Read the settings** (`repo.py`, `bite.py`): `.bite.ini` if there is one, otherwise a guessed test command + (pytest, npm test, cargo, go, dotnet, Maven, Gradle). +2. **Find the commits** (`recent.commits`): the last 40 that changed code and claim a fix, or all of them with + `--any`. +3. **Copy the project** (`recent.export`): `git archive` of each commit into a fresh folder, with submodules + and LFS files put back. Your working tree is never touched. +4. **Take the change out** (`recent.take_out`) in the copy, only in the language the tests run, and run the tests + (`bite.run_tests`). If they still pass, no test guards the change. Failed tests are rerun alone first when + their names can be read safely (`recent.only_these`), which saves whole-suite runs. +5. **Rule out harmless reasons** (other OS, tidy-up, a later fix) and look for a later commit that put the old + code back (the comeback alarm). +6. **Report** (`recent.write_free`, `write_html`, `write_comment`): `bite_proof/report.html`, `FREE_REPORT.md`, + `--json`, and for the Action a pull request comment with every @mention broken (`recent.no_pings`). + +## The paid step + +For the top suspects, `recent.try_claim` starts a worker through the Claude Agent SDK on a copy of the project at +that commit. The worker writes one small test of the commit's claim. Every tool call goes through +`bite.make_permission`: reads and writes must stay inside the copy (`read_ok`, `edit_ok`), shell commands must +pass the command filter (`command_ok`), and files that can run code or steer agents are held for a person to +review (`REVIEW_ONLY_DEFAULT`). Bite then runs the test itself, twice, on that commit and on today's code, and a +second fresh worker must agree the test is fair before it is shown. It needs an Anthropic API key (never a +Claude login) and stops at `--budget`. + +## The other front doors + +- `live.py`: `bite live` checks the changes since the last commit; `--hook` is the Claude Code Stop hook in + `plugin-live/`. +- `bite_mcp.py`: an MCP server (JSON-RPC on stdin/stdout) with `check_fix` and `ask_bite`. +- `ask.py`: `bite ask "..."` finds the commits a question means and runs the free check on them. +- `action.yml`, `open_pr.py`, `publish_badge.py`: the GitHub Action, which runs the free check on a pull request, + comments, and can open a pull request with the tests Bite wrote or publish a score badge. +- `bot/`: the repo's own helpers (welcome, PR checklist, self-check, Night Clerk). They are not shipped on PyPI. + +## Tests + +`tests/` holds about 670 tests, all offline. Most build a small practice repo, run `recent.py` on it in a +subprocess, and check what it prints. CI runs them on Linux, macOS and Windows with Python 3.10 and 3.13, measures +statement coverage (80% or more, counting those subprocess runs), and runs the Atheris fuzzer +(`tests/fuzz_atheris.py`) against the security checks. See [CONTRIBUTING.md](../CONTRIBUTING.md). diff --git a/docs/security-design.md b/docs/security-design.md new file mode 100644 index 0000000..5fd45d6 --- /dev/null +++ b/docs/security-design.md @@ -0,0 +1,94 @@ +# Bite's security design + +What you can and can't expect from Bite in terms of security, and why we think those promises hold (an +"assurance case"). To report a hole, see [SECURITY.md](../SECURITY.md). How the code fits together: +[architecture.md](architecture.md). + +## What you can expect + +1. **Bite's own steps never change your project's code.** Every check runs on a fresh copy made with + `git archive`. Your code, branches and git history are only read, and the paid step's worker only edits its + copy. Two exceptions, said plainly: + - **`bite_proof/`** is Bite's own output folder in your project. Bite reuses it, overwrites its report files + there (`report.html`, `FREE_REPORT.md`, `COMMENT.md`, `results.json` and others), and replaces + `bite_proof/missing_tests/` on each run that gets as far as saving results. It writes a `.gitignore` there + when there isn't one; that keeps new files out of git, but a file git already tracks stays tracked. Keep your + own files somewhere else. + - **`node_modules/`** in a JavaScript project is linked into each copy, not copied, so Node finds your + packages. A test that writes into `node_modules` (a cache, say) writes into your real one. +2. **Your API key stays yours.** Bite reads it from `ANTHROPIC_API_KEY` or `key.txt` and sends it only to + Anthropic, through the Agent SDK, for the paid step. It is removed from the environment of every test run + (`bite.run_cmd` drops every `ANTHROPIC_*` and `CLAUDE_*` variable), and the worker may not read `key.txt` or + `.env` files. +3. **The paid step's worker stays inside its copy.** It may read and write only files inside the copy, never + `.git` or a secret file, and may run only commands the filter allows (read-only tools, the project's test + command, the programs you list). Files that can run code or steer an agent (`.github/*`, `CLAUDE.md`, + `Makefile`, `*.sh` and others) are held back for a person to review instead of being written. +4. **Nothing is sent anywhere you didn't ask for.** No telemetry. The network calls are: the PyPI version check, + a `git clone` of a link you give it, git-lfs fetching your own project's files, and the paid step's API calls. +5. **The GitHub Action doesn't hand secrets to pull request code.** It runs on `pull_request`, where a pull + request from a fork gets a read-only token and no secrets, and its comment breaks every @mention so a commit + title can't ping strangers. + +## What you can't expect + +- **Bite runs your project's tests, so it runs your project's code**, with your user's rights. That is the + point of a test run, and Bite can't make untrusted code safe. Checking a project you don't trust? Set + `contain_command` (AGENTS.md) so every test and worker command runs in a Docker box with no network (see the + next two points). +- **The command filter is a guard rail, not a sandbox.** It is tested and fuzzed hard, but a box + (`contain_command`) is the real wall. Use one for untrusted projects. +- **Bite doesn't check your box.** `contain_command` is a template you write: Bite fills in the project folder and + the command and runs it. It doesn't check that it really starts Docker, turns the network off (`--network none`) + or mounts only the copy. Write it with those, and try it once by hand before you trust it. +- **A result is not a security review** of your code. Bite tests what a commit claimed, nothing more. + +## Threat model + +| Who | What they control | What they might try | +|---|---|---| +| The project being checked | its code, tests, test output, commit messages, `.bite.ini` | make Bite run more than its tests, read the key, write outside the copy, ping people from a comment | +| The paid step's worker (an AI) | the commands and file edits it asks for | run a dangerous command, read secrets, edit files that run later (CI, hooks, agent settings) | +| A pull request author (Action) | the code and commits in their pull request | get the workflow's secrets or a write token | +| Someone on the network | traffic between Bite and PyPI, GitHub, Anthropic | tamper with downloads or read the key | + +## Trust boundaries + +1. **Bite and the project's code.** Crossed every time a test runs. Guarded by the copy, the scrubbed + environment, and optionally the Docker box. +2. **Bite and the worker.** Crossed on every tool call. Guarded by `bite.make_permission`: `read_ok`, + `edit_ok`, `command_ok` and the review-only list. +3. **Test output and the next command.** Failed test names from the output can be put on a rerun command line. + Guarded by an allowlist of characters (`recent.SAFE_ID`): anything else and the whole suite reruns. +4. **Commit text and GitHub.** Commit titles are quoted in comments. Guarded by `recent.no_pings`. +5. **This repo and PyPI.** Releases go out only from `publish.yml` through Trusted Publishing, signed by Sigstore. + +## Secure design principles applied + +- **Least privilege:** every workflow starts with `permissions: {}` or read-only and adds only what one job + needs; the worker gets only the tools and folders its job needs. +- **Fail-safe defaults:** the command filter is an allowlist; anything it can't read (odd quoting, unknown + programs, a path it can't resolve) is refused. A rerun name it can't vouch for means the whole suite runs. +- **Complete mediation:** every worker tool call goes through one permission function; there is no other path. +- **Economy of mechanism:** no runtime dependencies, standard library only, so there is less code to trust. +- **Separation:** the worker writes a test, but Bite runs it, twice, and a second fresh worker judges it. +- **Open design:** all of it is public, including the tricks that still fool it ([TRICKS.md](../TRICKS.md)). + +## Common weaknesses and how they're countered + +| Weakness | Where it could happen | What counters it | +|---|---|---| +| OS command injection (CWE-78) | the worker's commands; rerun commands built from test output | the command filter (`command_ok`, `DANGER`, `SAFE_COMMANDS`, `SAFE_GIT`), the rerun name allowlist; both fuzzed by Atheris | +| Path traversal and link following (CWE-22, CWE-59) | the worker's file reads and writes | `inside()` resolves the real path, symlinks included, and refuses anything outside the copy; fuzzed against `os.path.realpath` | +| Exposure of secrets (CWE-200, CWE-522) | test runs, worker reads, logs | key removed from test environments, secret files refused, fuzz CI logs print no inputs | +| Untrusted code in CI with secrets (CWE-829) | the GitHub Action and this repo's workflows | pull request code runs only under `pull_request` (the one `pull_request_target` workflow, `welcome.yml`, never checks out pull request code), actions pinned to commit SHAs, hash-pinned Python tools | +| Unwanted notifications (spam via mentions) | pull request comments | `no_pings`, tested with Hypothesis property tests | +| Crashes on odd input (CWE-20) | test output, odd repos, odd file names | allowlists where data becomes code, hundreds of odd-input tests, the fuzzer checks the filters never raise | +| Tampered downloads (CWE-494) | Bite's own release | Trusted Publishing, Sigstore-signed PyPI releases ([SECURITY.md](../SECURITY.md#check-a-release)) | + +## How this is checked + +- About 670 offline tests on Linux, macOS and Windows, at least 80% statement coverage, enforced in CI. +- [Atheris](https://github.com/google/atheris) fuzzing of the command filter, the worker's file access and the + rerun command: 1 minute on pull requests that touch them, 10 minutes every week (`.github/workflows/fuzz.yml`). +- CodeQL and OpenSSF Scorecard on every merge to `main`; Dependabot for dependencies; ruff in CI. diff --git a/pyproject.toml b/pyproject.toml index 8a0111c..83456fd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,3 +48,15 @@ extend-exclude = ["bite_check.egg-info"] [tool.ruff.lint] # Real mistakes only (unused names, undefined names, syntax that breaks on Python 3.10), not style. select = ["F", "E9"] + +[tool.coverage.run] +# CI's coverage job (tests.yml) counts the Bite runs the tests start in subprocesses too: most tests run recent.py +# on a practice repo. Set COVERAGE_ROOT to this folder's full path: those runs start in other folders. +patch = ["subprocess"] +parallel = true +source = ["${COVERAGE_ROOT-.}"] +data_file = "${COVERAGE_ROOT-.}/.coverage" +omit = ["*/tests/*"] + +[tool.coverage.report] +fail_under = 80 diff --git a/recent.py b/recent.py index e5bad04..86e901c 100644 --- a/recent.py +++ b/recent.py @@ -1369,9 +1369,11 @@ def set_aside(root: Path, c: dict, fcfg, folder: Path, now: dict): if not PYTEST_RUNNER.search(cmd) or ONE_COMMAND.search(cmd) or fcfg.contain or now.get("hung") \ or now["out"].startswith("not run:") or bite.load_failure(now["out"]): return None - ids = list(dict.fromkeys(FAILED_ID.findall(now["out"]))) + ids = failed_ids(now["out"]) if not ids or len(ids) > MAX_ASIDE or not re.search(r"\b\d+ passed\b", now["out"]): return None + if not all(re.fullmatch(SAFE_ID, i) for i in ids): + return None # an id the shell would read ($(id), a quote, a space) never goes into a --deselect own = {t.replace("\\", "/") for t in c.get("test_code", [])} if any(i.split("::")[0] in own for i in ids): return None # the commit's own test: deselecting it would hide the very thing Bite checks @@ -1799,7 +1801,20 @@ async def nothing(*a): return last_json(text) -FAILED_ID = re.compile(r"^(?:FAILED|ERROR) (\S+::[^\s\"]+)", re.M) # pytest's summary: FAILED tests/t.py::test_x - ... +# pytest's summary: FAILED tests/t.py::test_x - message. A plain scan to the end of the line (no backtracking, so a +# long line of test output costs one pass); failed_ids() then cuts the id at " - ". +FAILED_ID = re.compile(r"^(?:FAILED|ERROR) (\S*?::[^\n]*)", re.M) +# A failed test id Bite may put back on a command line, inside double quotes. A parametrized id can hold anything its +# test printed ($(id), `id`, %PATH%, a quote, a space): those would run or break in bash and cmd, so the whole suite +# reruns. Brackets come only as one closing [...] group, so an id cut short at a " - " inside it +# (test_x[a - b] read as test_x[a) is refused too. +_ID_CHARS = r"\w./:\-,=+@#~()" +SAFE_ID = rf"[{_ID_CHARS}]+(?:\[[{_ID_CHARS}\[\]]*\])?" + + +def failed_ids(out: str) -> list: + """The failed test ids in pytest's summary, each once, in order: the words after FAILED/ERROR up to " - ".""" + return list(dict.fromkeys(m.split(" - ", 1)[0].rstrip() for m in FAILED_ID.findall(out))) GO_FAILED = re.compile(r"^\s*--- FAIL: ([A-Za-z_]\w*)", re.M) # go test: --- FAIL: TestTotal (0.00s), subtests TestX/case CARGO_FAILED = re.compile(r"^test (\S+) \.\.\. FAILED$", re.M) # cargo test: test tests::rounds ... FAILED DOTNET_FAILED = re.compile(r"^\s*Failed (\S+) \[", re.M) # dotnet test: " Failed Shop.Tests.Rounds [12 ms]" @@ -1812,10 +1827,10 @@ def only_these(cmd: str, out: str, folder: Path) -> str: cargo test: those names with --exact. dotnet test: a --filter of their full names. Others (npm test, Maven, Gradle) print failures too many ways to pick them out safely, so the whole suite answers there.""" def names(pattern, ok=r"[\w:.]+"): - found = list(dict.fromkeys(pattern.findall(out))) + found = failed_ids(out) if pattern is FAILED_ID else list(dict.fromkeys(pattern.findall(out))) return found if found and len(found) <= 40 and all(re.fullmatch(ok, n) for n in found) else [] if "pytest" in cmd: - ids = names(FAILED_ID, r"\S+") + ids = names(FAILED_ID, SAFE_ID) return pytest_one_file(cmd, " ".join(f'"{i}"' for i in ids), folder) if ids else "" if ONE_COMMAND.search(cmd): return "" diff --git a/tests/fuzz_atheris.py b/tests/fuzz_atheris.py index a4b4365..aa388a1 100644 --- a/tests/fuzz_atheris.py +++ b/tests/fuzz_atheris.py @@ -1,8 +1,10 @@ -"""Coverage-guided fuzzer for the worker's command filter (Atheris, Google's libFuzzer for Python). +"""Coverage-guided fuzzer for Bite's three security lines (Atheris, Google's libFuzzer for Python). -The paid step's worker may only run commands that bite.command_ok() lets through, so that filter is Bite's -main security line (SECURITY.md). This feeds it random commands, half raw text and half built from real shell -pieces (rm, curl, quotes, pipes, ../, key.txt ...), keeps the inputs that reach new code, and checks: +Each input picks one target and keeps the inputs that reach new code: + +1. The worker's command filter. The paid step's worker may only run commands that bite.command_ok() lets + through, so that filter is Bite's main security line (SECURITY.md). It gets random commands, half raw text + and half built from real shell pieces (rm, curl, quotes, pipes, ../, key.txt ...), and the fuzzer checks: - command_ok, split_commands, unquoted, uses_program and is_secret never raise on any text - a command it lets through, read word by word the way the shell reads it (shlex, quotes removed), never @@ -10,6 +12,15 @@ output file or any program --output (tests/fuzz_oracle.py: an oracle of its own, not the filter's checks run twice; it flags find . -de"lete" against the old filter) +2. The worker's file access. bite.edit_ok() and bite.read_ok() decide which files the worker may write and read. + A path they allow must stay inside the project copy (no .., no absolute path, no symlink pointing out), out of + .git and off secret files, checked with os.path.realpath (fuzz_oracle.path_safe), not the filter's own code. + +3. The rerun command. recent.only_these() turns test output, which the project's own tests print, into a command + that reruns just the failed tests. Every name it adds must be one the output printed, and none may hold a + character bash or cmd.exe would expand inside quotes (fuzz_oracle.rerun_safe). It flagged + test_x[$(id)] against the old code, which put that id inside double quotes, where the shell runs it. + A break raises with no command in the message, so CI logs don't spell out a way past the filter (SECURITY.md). Not run by pytest (the file name doesn't start with test_). @@ -28,7 +39,8 @@ with atheris.instrument_imports(): import bite - from fuzz_oracle import shell_safe + import recent + from fuzz_oracle import path_safe, rerun_safe, shell_safe PIECES = ["ls", "cat", "grep -rn x .", "python -m pytest", "git log", "git push", "git -c x=y log", "rm -rf /", "curl http://x", "find . -delete", "\"find\"", "x\";\"", "echo", "key.txt", ".env", ".ENV.local", "../", "/etc/passwd", "~", @@ -37,9 +49,21 @@ "/dev/tcp/1/2", "timeout 5s", "cd ..", "cd sub", "C:\\Windows", "%USERPROFILE%", "format", "\t"] +PATH_PIECES = ["..", ".", "sub", "out", "link_out", ".git", "config", "key.txt", "KEY.TXT", ".env", ".env.local", + "a.py", "/", "//", "\\", "/etc", "/tmp", "~", "$HOME", "C:", "\x00", " ", "bite.py", "tests", "%2e%2e"] + +RUNNERS = ["python -m pytest -q", "cargo test", "dotnet test", "go test ./..."] +OUT_PIECES = ["FAILED ", "ERROR ", "tests/t.py::", "test_x", "[", "]", "$(id)", "`id`", "%PATH%", '"', "'", "\\", + "!", " - boom", "\n", "--- FAIL: ", "TestA", "test ", " ... FAILED", " Failed ", "Shop.Tests.A", " [1 ms]", + "::", "-1", ",", "(", ")", "${X}", ";", "|", "&&"] + + def make_config(): project = pathlib.Path(tempfile.mkdtemp(prefix="bite_fuzz_")) (project / "sub").mkdir() + (project / ".git").mkdir() + outside = pathlib.Path(tempfile.mkdtemp(prefix="bite_fuzz_out_")) + (project / "link_out").symlink_to(outside, target_is_directory=True) ini = project / "fuzz.ini" ini.write_text(f"[bite]\nproject_folder = {project}\nallowed_programs = python, pytest\n", encoding="utf-8") return bite.Config(ini) @@ -48,8 +72,37 @@ def make_config(): CFG = make_config() +def pick(fdp, pieces, most): + return "".join(pieces[fdp.ConsumeIntInRange(0, len(pieces) - 1)] for _ in range(fdp.ConsumeIntInRange(1, most))) + + +def file_access(fdp): + if fdp.ConsumeBool(): + path = fdp.ConsumeUnicodeNoSurrogates(120) + else: + path = pick(fdp, [p + "/" for p in PATH_PIECES] + PATH_PIECES, 8) + try: + allowed = [bite.edit_ok(path, CFG), bite.read_ok({"file_path": path}, CFG)] + except ValueError: + return # a NUL byte: Python refuses to open it at all, so nothing is reached + if any(allowed) and not path_safe(CFG.project, path, CFG.secrets): + raise AssertionError("the worker may touch a file outside its copy, in .git or a secret") + + +def rerun(fdp): + cmd = RUNNERS[fdp.ConsumeIntInRange(0, len(RUNNERS) - 1)] + out = fdp.ConsumeUnicodeNoSurrogates(300) if fdp.ConsumeBool() else pick(fdp, OUT_PIECES, 30) + if not rerun_safe(cmd, recent.only_these(cmd, out, CFG.project), out): + raise AssertionError("a rerun command holds a name the shell would expand, or one the tests never printed") + + def one_input(data): fdp = atheris.FuzzedDataProvider(data) + target = fdp.ConsumeIntInRange(0, 2) + if target == 1: + return file_access(fdp) + if target == 2: + return rerun(fdp) if fdp.ConsumeBool(): cmd = fdp.ConsumeUnicodeNoSurrogates(300) else: diff --git a/tests/fuzz_oracle.py b/tests/fuzz_oracle.py index 8b59353..fcff087 100644 --- a/tests/fuzz_oracle.py +++ b/tests/fuzz_oracle.py @@ -42,3 +42,69 @@ def shell_safe(cmd, secrets): if any(w.startswith("--output") for w in low): return False return True + + +def path_safe(project, file_path, secrets): + """False if file_path, opened from inside project, would land outside it (.., an absolute path, a symlink that + points out), inside .git, or on a secret file. Uses os.path.realpath, not the filter's Path.resolve().""" + import os + root = os.path.realpath(project) + target = os.path.realpath(os.path.join(root, file_path)) + if os.path.commonpath([root, target]) != root: + return False + rel = os.path.relpath(target, root).lower().split(os.sep) # on Linux a backslash is part of a name + if ".git" in rel: + return False + return not any(rel[-1] == s or rel[-1].startswith(s + ".") for s in secrets if "*" not in s and "?" not in s) + + +def printed(out): + """Every whole test name the output reports as failed, read line by line with looser patterns of the oracle's own + (not recent.py's, so a name they cut short isn't on this list): pytest "FAILED id - message" (the id runs to + " - "), cargo "test name ... FAILED", go "--- FAIL: Name/sub" (the parent test) and dotnet "Failed Name [1 ms]".""" + names = set() + for line in out.splitlines(): + if m := re.match(r"(?:FAILED|ERROR) (.+?)(?: - .*)?\s*$", line): + names.add(m.group(1)) + elif m := re.match(r"test (.+) \.\.\. FAILED$", line): + names.add(m.group(1)) + elif m := re.match(r"\s*--- FAIL: (\w+)", line): # a Go test's name is a Go identifier; /sub is its subtest + names.add(m.group(1)) + elif m := re.match(r"\s*Failed (.+?) \[", line): + names.add(m.group(1)) + return names + + +SHELL_READS = set("$`\\%!\"'") # inside "..." bash expands $ ` \ (and ! interactively); cmd.exe expands % + + +def rerun_safe(cmd, rerun, out): + """False if the rerun command Bite built from test output (recent.only_these) has a word the shell would + expand or that breaks the quoting, or a test name the output never printed.""" + if not rerun: + return True + if cmd.startswith("go test") and rerun.startswith("go test -run "): + try: + words = shlex.split(rerun, posix=True) + except ValueError: + return False + names = words[3].removeprefix("^(").removesuffix(")$").split("|") + return (" ".join(words[:2] + words[4:]) == cmd and '"' + words[3] + '"' in rerun + and all(re.fullmatch(r"\w+", n) and n in printed(out) for n in names)) + if not rerun.startswith(cmd): + return False + try: + added = shlex.split(rerun[len(cmd):], posix=True) + except ValueError: + return False + raw = rerun[len(cmd):] + for w in added: + if w.startswith("-") or w == "--": + continue # cargo's --exact and --, dotnet's --filter: Bite's own words + if w.startswith("FullyQualifiedName="): + names = [x.split("=", 1)[1] for x in w.split("|")] + else: + names = [w] + if any(n not in printed(out) for n in names): + return False + return not (SHELL_READS & set(raw.replace('"', ""))) diff --git a/tests/test_rerun_ids_stay_quoted.py b/tests/test_rerun_ids_stay_quoted.py new file mode 100644 index 0000000..24050b4 --- /dev/null +++ b/tests/test_rerun_ids_stay_quoted.py @@ -0,0 +1,107 @@ +"""A parametrized pytest id can hold whatever its test printed. Bite reruns failed tests by putting their ids back +on the command line inside double quotes, so an id like test_x[$(id)] would have run `id` in the shell, and +test_y[a"b] was cut short at the quote. Ids like those now make Bite rerun the whole suite instead. Found by the +fuzzer's rerun target (tests/fuzz_atheris.py). No key, no network.""" +import sys +from pathlib import Path + +import pytest + +sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) +import recent # noqa: E402 + + +@pytest.mark.parametrize("bad", ["test_x[$(id)]", "test_x[`id`]", 'test_y[a"b]', "test_z[%PATH%]", "test_w[a\\b]", + "test_v[${HOME}]", "test_u[!x]"]) +def test_an_id_the_shell_would_read_reruns_the_whole_suite(tmp_path, bad): + out = f"FAILED tests/t.py::test_ok - boom\nFAILED tests/t.py::{bad} - boom\n" + assert recent.only_these("python -m pytest -q", out, tmp_path) == "" + + +def test_plain_and_parametrized_ids_still_rerun_alone(tmp_path): + out = ("FAILED tests/t.py::test_ok - boom\nERROR tests/t.py::TestCart::test_add[1-2.5-x,y] - boom\n" + "FAILED tests/t.py::test_neg[-1] - boom\n") + cmd = recent.only_these("python -m pytest -q", out, tmp_path) + assert cmd == ('python -m pytest -q "tests/t.py::test_ok" "tests/t.py::TestCart::test_add[1-2.5-x,y]" ' + '"tests/t.py::test_neg[-1]"') + + +def test_the_fuzzer_oracles_catch_what_they_should(tmp_path): + """The fuzzer's own checks (tests/fuzz_oracle.py), without atheris: a symlink out of the project, .git and a + secret are unsafe paths; an id inside quotes with $( is an unsafe rerun, and so is a name the output never + printed.""" + sys.path.insert(0, str(Path(__file__).resolve().parent)) + from fuzz_oracle import path_safe, rerun_safe + project, outside = tmp_path / "p", tmp_path / "outside" + (project / "sub").mkdir(parents=True) + outside.mkdir() + try: + (project / "link_out").symlink_to(outside, target_is_directory=True) + assert not path_safe(project, "link_out/x.py", ["key.txt"]) + except OSError: + pass # Windows without symlink rights + assert path_safe(project, "sub/x.py", ["key.txt"]) + for bad in ("../x.py", str(outside / "x.py"), ".git/config", "sub/KEY.TXT", ".env.local"): + assert not path_safe(project, bad, ["key.txt", ".env"]), bad + out = "FAILED t.py::test_x[$(id)] - boom\n" + assert not rerun_safe("pytest", 'pytest "t.py::test_x[$(id)]"', out) + assert not rerun_safe("pytest", 'pytest "t.py::test_never_ran"', out) + assert rerun_safe("pytest", 'pytest "t.py::test_ok"', "FAILED t.py::test_ok - boom") + assert rerun_safe("go test ./...", 'go test -run "^(TestA|TestB)$" ./...', "--- FAIL: TestA\n--- FAIL: TestB") + + +def test_an_id_with_spaces_is_read_whole_and_refused(tmp_path): + """pytest prints test_x[1 2] with its space; the id used to be cut at the space into test_x[1.""" + out = "FAILED tests/t.py::test_x[1 2] - boom\nFAILED tests/t.py::test_ok\n" + assert recent.failed_ids(out) == ["tests/t.py::test_x[1 2]", "tests/t.py::test_ok"] + assert recent.only_these("python -m pytest -q", out, tmp_path) == "" + + +def test_setting_tests_aside_never_builds_a_deselect_the_shell_would_read(tmp_path, monkeypatch): + """The set-aside step (tests that fail with nothing taken out get --deselect) used the same ids, and its command + also goes into FREE_REPORT.md's rerun recipe. An id like test_x[$(id)] now means no set-aside at all.""" + import bite + ini = tmp_path / "b.ini" + ini.write_text(f"[bite]\nproject_folder = {tmp_path}\ntest_command = python -m pytest -q\n", encoding="utf-8") + cfg = bite.Config(ini) + ran = [] + monkeypatch.setattr(recent.repo, "git", lambda *a, **k: "") + monkeypatch.setattr(recent, "pass_today", lambda *a, **k: True) + monkeypatch.setattr(recent, "run_tests", lambda sub, *a, **k: ran.append(sub.test_cmd) or {"ok": True, "out": "3 passed"}) + monkeypatch.setattr(recent, "doing", lambda *a, **k: None) + now = {"out": "FAILED tests/t.py::test_x[$(id)] - boom\n1 failed, 3 passed\n"} + assert recent.set_aside(tmp_path, {"sha": "abc", "test_code": []}, cfg, tmp_path, now) is None + assert not ran + now = {"out": "FAILED tests/t.py::test_x[1] - boom\n1 failed, 3 passed\n"} + assert recent.set_aside(tmp_path, {"sha": "abc", "test_code": []}, cfg, tmp_path, now) is not None + assert ran == ['python -m pytest -q --deselect "tests/t.py::test_x[1]"'] + + +def test_the_rerun_oracle_wants_whole_names(): + """The oracle compares whole reported names: a selector cut short at a space isn't one the tests printed.""" + sys.path.insert(0, str(Path(__file__).resolve().parent)) + from fuzz_oracle import rerun_safe + out = "FAILED tests/t.py::test_x[1 2] - boom\n" + assert not rerun_safe("pytest", 'pytest "tests/t.py::test_x[1"', out) + assert rerun_safe("pytest", 'pytest "tests/t.py::test_ok"', "FAILED tests/t.py::test_ok - boom") + assert rerun_safe("cargo test", "cargo test -- --exact tests::rounds", "test tests::rounds ... FAILED") + assert rerun_safe("dotnet test", 'dotnet test --filter "FullyQualifiedName=Shop.A"', " Failed Shop.A [1 ms]") + + +def test_an_id_cut_short_at_an_inner_dash_is_refused(tmp_path): + """test_x[a - b] is read up to the first " - " as test_x[a: its bracket never closes, so it can't be the id.""" + out = "FAILED tests/t.py::test_x[a - b] - boom\nFAILED tests/t.py::test_ok - boom\n" + assert recent.only_these("python -m pytest -q", out, tmp_path) == "" + out = "FAILED tests/t.py::test_x[a-b] - boom\nFAILED tests/t.py::test_y[a[1]] - boom\n" + assert recent.only_these("python -m pytest -q", out, tmp_path).endswith( + '"tests/t.py::test_x[a-b]" "tests/t.py::test_y[a[1]]"') + + +def test_a_huge_summary_line_is_read_in_one_pass(): + """Test output is the project's, and Bite reads it after the run, past the test timeout. A long line of spaces + used to make the summary pattern backtrack; now it's one linear scan.""" + import time + out = "FAILED tests/t.py::test_x" + " " * 200_000 + "x\n" + "FAILED " + "a" * 200_000 + "\n" + start = time.perf_counter() + assert recent.failed_ids(out) == ["tests/t.py::test_x" + " " * 200_000 + "x"] + assert time.perf_counter() - start < 2