From 3bace4c7352c254366669b53c87173b1f52154ff Mon Sep 17 00:00:00 2001 From: Zachary Rice Date: Sun, 7 Aug 2022 12:53:58 -0500 Subject: [PATCH] Feat/ignore finding (#938) --- .gitleaksignore | 651 ++++++++++++++++++++++ README.md | 4 + cmd/detect.go | 5 + detect/detect.go | 39 +- detect/detect_test.go | 3 + detect/utils.go | 6 + report/csv.go | 2 + report/csv_test.go | 1 + report/finding.go | 3 + testdata/expected/report/csv_simple.csv | 4 +- testdata/expected/report/json_simple.json | 3 +- 11 files changed, 713 insertions(+), 8 deletions(-) create mode 100644 .gitleaksignore diff --git a/.gitleaksignore b/.gitleaksignore new file mode 100644 index 000000000..7e6344358 --- /dev/null +++ b/.gitleaksignore @@ -0,0 +1,651 @@ +8656cc293af402e7ceb6ced7e46e414eaa10580a +45b529c43aeb51d2ff6a3f2d41a02f7f198c9596 +6a9d4871efd8f3f633be13207e106f1eb737d3c8 +e10031fcb03002201520cf816ca6181e766d4aef +ecfa2585fcc57efc6b7fadc79751edf7ce813314 +f83d359c45ca2ccd505bd849c78ac406a5352548 +d05ca0b9c00691d20ac898ccfb5f651f369d0e46 +7599de90a03099fb94725bed3704888eb3410c9b +5497f8b33c6de81a8ae6b5f0fc11f06318d4e412 +eafd668f0b403b85a7fa10ea965971bf92d516e4 +d2d135e115c346aa8ac995e82855a9a92a89ae0e +b23fd6198cd9c60affa7bb51f14f4679815ed286 +7c075749875143ad5eb162b8c9dd56cf2460d50e +89166396f3d6a3c1a7841e7c354c0e9a0b4ea3f0 +cce986b1baccd43bd30bd92a6cda0ed6982135f1 +d7f34ff7ef2e878e797526da2159269a4553c872 +61f3533994a70eff4183343f9b516fb8ef720c93 +20eadcbf3c32e60875d31ab9125cb4ab72317bef +24e720ae74cd710640f1be726cd1965fadcbb359 +24e720ae74cd710640f1be726cd1965fadcbb359 +70d7d00365746c6f9081fcb2a382f4b04e3e36e2 +920e6e754820b0c29b9ac94de567b09988279599 +59f5b5a3ec2888d7be7d193ee9784175b98926e1 +656434da2ec14d1f51edc5fa74dc5d2d08706f67 +837fa0e0d223e7fa1796d31956e652aee935f013 +f378fe53d5c1688bf32f2a208d4a047808105bed +b2eb017e5806e56a645d8c0b1764b21b23d175a7 +2ba33e2800af6945b5ce648521646277103a0975 +845a01eda57d9808314db564f880bad2aa633bea +66d1439830a50eecae9e28d9652e247f3ac4984c +22cdfe655be3e44d85a7fdb638af5ee26ee2422d +0f3f4c27c6704694f8f3264de8c65fe4370d53c2 +4bf2469fb58ad3e8e497bd42767c13d6ad6cd01d +1bcd1da32d94b88094269bfc60c4f59d8bdeac1b +50340bfd6c5c8d7c58926d33936bac76ea2df9bc +878b808b2d4631f5895783529287faf93b2726a7 +0456c652586bec4dcc1eee5428987cd6d748e896 +6d223fcac49bd96ed5e2a303fea6be0a04985014 +b6bf1f2ebe0d6f10a7ec34188e9636052efafc6c +3840f62e06d74ff175ea5a8312ad509bd9769351 +d8f974bbe4ebe23b8f387f8d47d4fc61c75598c2 +63883ded02136bbefad8edd5336da69f41e0bcb2 +84402c1d0abdf8ec80ef23f88b1caf5fdf4b1566 +8500a762bed92fa8ce40486c78ad404fc227067b +f9d3a00843fccd9055761aa835631785ef01cfa3 +4f6792ab2db5f4ccab1f856d49f42f26efe1e89e +56492efd6e62cd8bb68b818a611f1ad8991b4153 +0e8876db1228a44a44b91aceb3e07fb8f58cb0cd +6ded6a326a6992a183d1e9de0f93e4ca27e47621 +f795edeb5dd8ae1467b11f8df7bc8e363ae7166e +6131f865b3306a7c56245f84dd71c2c8046ab361 +29d12c5fb8fac880459c85bb706a0758e86f300a +590b619b6c76d4e4188bdc6859d33b7a22c8a616 +b4debfecf0c0856b5723985a46716e9e49c54b7b +19d26c58a914b557057e5bd9e00a487aa5182fdd +68de55079e97cf5ff6dc803411f95359feb29c7b +2d15093e1d1ea78e60742fa0521e7aeb8d094dc5 +2a6d2e5b879453b39d6a0ea0e6f51474e5a2fa9a +90a904d1f08c9e19324b04aaa2e5ccedaf4cd933 +d36b9a3a50d2cc8f197b9a7f071f0fabb2996808 +923919d7658e394e2448216dd97ecb826490a42d +105dee3ba3319c012bf15458be218ca6dbd360f1 +daf6941c98ddc345836f4df9c03fbf6e8371bba0 +f0f00ddf38946a666805c22ee4bdbdfeb0fdd186 +9502ce49a6a07515a1c1826342c1fee5d2afeadf +3cc64ba8557f6d054f9c63fe225c6d971314c2d8 +3fb0787f3468a5cd57b75df04634fa7a3a2d2eb3 +4983563275c91a5ed9a7558b61011d1e106aa47e +2994f3863c011cc6874bb656b87a6b793db28213 +f9d3a00843fccd9055761aa835631785ef01cfa3 +66337c40e03e2ed82382eb679be1f06912e5c927 +665f66e005b30d048bc71224a1364e7bdeb66df5 +bcc0221ce5dbb136567c55ee42acb3e0d313f08b +e67945c4c4a0ca3d435eb8caa4a4b349d53fa4a5 +6cb1f4876acb9b44b2e2f165b453d42afc8e1219 +6e7c436c45d49b2676a3704e7df95d4ba530c675 +1b4d1aa84a0264620e12c404699d59bc776d486e +7647cf080c6bf681e5b10d23ebbfacbf2c613ef4 +b2eee866b7c6c76862a9100a44e496ca98558573 +96ba18cdaa05323ada9ffbd8261b17c1bd9ff00c +dceccb04506f7020fe9b67bcfb2d7afa36b7eecf +a1b7928343b0477ea2c6b8b2445b262073c4a49e +bf462c7b3d9e85102c652dedff15e586dec6f4c1 +49c9b547afaf145c63fca614f5a3e762495f09b5 +a1eaad75316bf370083a6bb76f7f35cdaec0c1e5 +9fbb3bd773b29ae4df2e09b12b9fcc5448fc8360 +011844370ce89f1973c9d80809b4eb06411f139f +1d3b4f7ccedab21f854d8711654cc613831a1118 +a69862b4e3406570d74ee4e2d7dd863f16b7fb17 +11848fd18b1772c0584f1590fd80f6ff36a228ae +5741f362f3769f10719ab5406afed302b8df1e95 +efab13882a0c8ae529f8a39458a158505f63ea80 +101f20cc18ec9cb72d185e47e2da661efab9109f +50ca343374c58f57f83da0ebff8445dd390c1733 +cfde569ad1c4b3edf517a986c1ac96990c258353 +24e720ae74cd710640f1be726cd1965fadcbb359 +a1eaad75316bf370083a6bb76f7f35cdaec0c1e5 +b2780c8889c3825f4f392e80e02c6029ece40b93 +9fbb3bd773b29ae4df2e09b12b9fcc5448fc8360 +d7bd4230e4d5f43bb1d5004edafa9835affdae27 +1c5081ff4518a9ff9b4bc008e70d3da0679b1315 +fdc7ec908b9709ce61ab123041958987a44595cd +5aee1920b415df35f887ce12eae6f2162f488b80 +1b4d1aa84a0264620e12c404699d59bc776d486e +d39ff83940311147d094380ad4cc136e662bf512 +276ead08acb0953bcdd990e138d01dfcce6c1b55 +011844370ce89f1973c9d80809b4eb06411f139f +bf0e5b0b8458ca5a91da8def5eff2924dc4172f3 +efab13882a0c8ae529f8a39458a158505f63ea80 +149c663a7a3611ba9ed15093f0f52e94001a1ee1 +0064094c34fdb036d15617cded9dadd812327953 +4af38de80134934c4ca7514c927405367e3f3fee +e11e1c812cfcc969d350822046acfb211c0e9164 +6f63a86cd8190bbe0176afdcabeabbbe14d7b69c +5da2d2c9f8b880a6fd5dfd023125eb39b769e7c0 +695825fa48e0b7fd3e3bf42495e947ca327866cb +0547070c24aea64e4a4d394a9133c6fc5b3182c4 +b2a1eebde836b7ef2dccb9670c4da065d55b39d7 +6163425830de08fc8b0834d4fa8ca784d79fef69 +43442bb0fa5fd5309fdc9c297cf042e2ac24e8b8 +94870c87d178f4150ed3d3f0d8ab50fd53cf759b +56801e445479a9985b2a749054ca0bd59689917f +9d3497c1a259ca1a180109726f6a0cda12fe1fe8 +5129f575eca472a2849c329e4ff6d3a79b0316f1 +0996aaa1d78bfeba6971ffb070e53d624d3db4a5 +67432867949cc2a42f65ecb24d8da1c2a09e5ce1 +6cf692a655e1c846f2501a73c87cddb21906bbfb +df8e0c0e697206e4392a3996c64d82daa2adda53 +450e434158643f8585bf7e4bdf192c3694881a96 +c1236f3c26106e3f798e3f5178a56d81d4e26b56 +d32c483608ac98220b898ad1beea1d86cfce7ce7 +58735a17bff3f6543bb3f7524d0dbb7eec3bfb40 +bbf918e3b32a8492487566ab48cdab4126ac14cf +e6b31b51beb35a2fcc26c0f95f4d58f435b29e3d +a1da2890efbf003acfeba2dda8280867d2e2d522 +1b41a3d3b77da3ec2d0258e9785c5f6abbe177d6 +a761e4447a8eaefbb1f185f7ab0db2a1a608c7a0 +577580802e7cc47d663e7987b8ac5c0ac01384c5 +c1f390ed2913853905a6ab32a7e9a0f156fb6420 +d1d508bd130081bdfc2094791f9e2be432ed8875 +a665d7534b36bbdbb0a67351bbc20fba5eb8b34e +63628bebc1ab0d6778daf29d2fe70afeeaa5986b +2e3020fc4d780c45179f3f6c38855dc7fc03ee8f +8285db5920b43d767790b452dd7309a49b55c094 +bb831e30d8d713d4de52ea65f581f0f360fb25f8 +ea3bc6103c9e881e2b7c00f076c07dee577abc7d +b328312c7328508246a2ce0a9f2aa44ee619c87c +c024909e43a01473ac6a090159eb49b7eceed939 +7da51cf58cd6d4ac241c9a2a5ab8ce3f4d7b4055 +59a78f51b0adf7cda2ded2c06145459c210b24cc +8c23f8e87cbfda15af45512cc8c97d0f24ee1708 +d955f1f8b9636eb0cedbedd73bb829ac278ee76e +e51c04ee8e17cfe4fe6369edad2e975736df0497 +10919239c91e5c696ff7d4f0d48d0eac6a354f55 +4ea2354ff7786526e42ecf215276a9c89c1dcef8 +225ef190a71bdb37e7894e5598f8b43e4b9a2aac +ff9a3583784717e2ac340beb9b510abf9bc0dbb3 +efa49ccd7904af825fb5b790c3bd1ae47da867a4 +9bfe51eaff52f93b2f86c03fc47bc2fa43ed631c +ee65ce6f83d3affee8e7cffef9c9af9147920acb +f01a37da32d0a4f3069d138c6a8bc27415ac01c5 +1da23ea0221b5f79cfe22ed5348e35f2a31c2301 +b2040bdb3ebbdc1cb05f73174a2206cc4c3e0de4 +9fe2b908f4402097a10fadb64d766221a0302fc5 +b55919dbb9a7a20167dc2c7f64dfb1186743d954 +cf22fba89a4e934a4ce812e7e2ffdd0fc00931b7 +af54c51cdb8fe4c8c1263ebad110ca941a4162eb +26215f2ef006c804d2882f26eb5a4d4e8da63fd9 +861a048729daf36d1371ce7889e46022f1b52666 +2c29d89dda12713aa423f69be4b56a32c60afece +69101efa97fb6a31489099f97ca4b94b524ba98f +60a68a6eb7357986fa4e219051580be615a92af7 +5744d957a3189c0678271de07327e24368cdc388 +d85cb8c914348f279ad277a51018a13d894cdd5c +4242fc70096c44be514b9cb2901dda7c481d004e +aa8fc3c7e943fee0de1d827bda60d29e01d41257 +974339b23f0d1887e99a109605ade66873e03e76 +667b02a4625a4e887c446c2dfa1ee8fc6ad48e4f +1a179404d34790a33968e75d18000051da788ac1 +7b8d8229ebfe8975bf588daeef23ab028c171c77 +9ff2611468cb5d69a9f45d0a377383bc431acbce +25a983b662281383b467727fbf25ccb2400a3233 +a370878c45ae17b90ebe32145e45962077431df8 +20a03c2c8ba119cb7450f628cd91b48ee3fede9d +e8d9bd2ccc9cec6ed46ceca4eda813406c7f5c5a +6229236a6826f8e80b21e07b89103256addd5606 +071f1aa1a3ffd3158e9ab7cfa42d3f5fb4659ff7 +3cd2e47f545fbd0ec1686ba0fb182f2a23538af3 +e602e4516cd3fc1de82352c251511f10050cb623 +b18c27d6d8a9b26a1d038774030428d00eb5c078 +32d690b1493899bcb00d70a6dfecc79cdcb4346c +ba2e3efea88a91ac27e1145fa5ba9d47951429df +b9d0cccd3fabc9c967974e9aa573704f72c9367d +c0ee8bac542325503962d2d5cbe7734fc3d35ffc +942deeb6dde57f32928bba86266c6a2cb180b1ae +b6eac06026e6c7622dac0ddfd366a4d31913fac4 +d1b27799601a9cb6bddd79972abe28546a468331 +e405b9ea7be88bf56ed3d54dececd0d8fdfeae4b +b3a4ce34d34940479f10ad283867f8479d160848 +b721a924696758e3c59fe2526ea64aee7e5a7142 +301de6402305c92444f72c4100f1cdc6f5a8a80e +5e1c236e8fc251fbfb3516a6c67bbae797064350 +114148673088beb5f2ded0105e960d123f0557e8 +82aeea0fc1ed0a5a8d64568fc0c4ae2e7baa2137 +20c160a4cb7b095e310f3b35ce00ca73dafe4503 +8f7a779692814e022183d0b03107964c6af5726b +e8d9bd2ccc9cec6ed46ceca4eda813406c7f5c5a +6229236a6826f8e80b21e07b89103256addd5606 +071f1aa1a3ffd3158e9ab7cfa42d3f5fb4659ff7 +3cd2e47f545fbd0ec1686ba0fb182f2a23538af3 +4f3cef974f7059a4a83680d4802ba845f58b97fc +7f850a4383e12b63efeaf9c30d9dd70a9a88b3c9 +e602e4516cd3fc1de82352c251511f10050cb623 +f0c9acde0360ab4c551e753c281967d61fc12173 +2ac249303340fba15cfd8bedb6f5c237a5fe0504 +a71aa259a475041e809d2a1c8ea08d50dbfa4c35 +4a4df199566ea8107df3032889cdeafc1073bbb1 +b5f8a3d03fd20f47ae73f8b5f249e90e8aecd91b +7d73f7a38c9e10f9436e8bca5f1507855f5cf041 +43aa054d56f0007af32b9fa0db452bb960d72de3 +6ddc1b9b3c1c0d34d1e4a317f5bd7e64b85fbf9b +17a9d74a79ed8600e071d4442e6a64ec27ce71ae +67f2943bd9e41cefaa576efe55fd8d8e4c8a0c46 +71639222f100f4e30987278bb2cadfde3bf6b010 +2c91ec521f6e2f5a7ddf924eb659b7a37d1763e3 +3f2e3e2c4220bf59edf9fd86a43eda065dce783c +1a4db18a1ab480487beae644abfbd3bd42bedc28 +30421bf31225f5f50e93de2691e9fd29da8d353c +aed1a4d2c57b84e116e35ab7485b3f1b8e63fd39 +2e00e84c3dded9ce67d0023b3b59c97e845df6f2 +77ccd154edd55720317f4035ef3825be13ad9e0f +c5c03a40ca63dbde3aa4f07305fa955153db8562 +e525af918587300d4ae0487b25ee6d61c16a9980 +0a7cd16c55f06bfbbc1e61dc81ba8f8edca0b6e4 +07775c76f1def4d155a50a9a2cdbbb0a584fe351 +b6a619473a893ac0a4836a469fc1d581d3a84474 +974339b23f0d1887e99a109605ade66873e03e76 +667b02a4625a4e887c446c2dfa1ee8fc6ad48e4f +645791746e79b2f3118a0eca79dbbae6fa6191a4 +58deb6da6c2bb3a72b9f7154d8f823a4f32e3316 +d07a2bc0c5d11ddd2edbd6c4fdf3d00969aaba2c +dad04a7300d93f04117f7bb51e04a1b8d0a92f53 +871e4e678f1075f84ad61572f9c984c09e4bcc91 +02531cfc5ba230d1fd00d879134eeed4443bdf64 +461f1937da031b6ec9209cdad5c11075d6cd3a38 +d88b5012fb32111d20a55f6a41f09f2c33da8a12 +85c863d075bee457f3b79372023b7c334427a4c2 +c7961c2fc29b29b486c937e67d46cf97023958b7 +70b2f472080ae66d648553c0f50148a57b65b831 +588fcd07a724285a1ff89b25635cef743785f557 +4b9b603f32afdcc8466e0a32302974f77470ef50 +2f5acfd0b66e07f6b19573d1a2b0d9ba1430d465 +aded71fb1d6c65e193d12a6232eb2c5664169110 +61e37793101b8702664dc774c0579173a2f87fab +a7ea49b677045512a85e16c53abf74966e6ab734 +ea8418534a1cc1dd7fe66de51a17a16a740e8222 +7c9caf8f669303c5e7129fe166b0c59b7df870a6 +2683e6e53e9f6574c2a6eca41d5d2dde85d55e0b +faa6ded5389576b487f0ad085a76fdd7d2372471 +3c0ad6d68991961e2a72422fa4f69ed70d4ae6ab +a64da44ddc1cba77229ba024cac0948cb96a7676 +9f59d00d9f3f34d0c368a02d6e1cc2cd3e80f4a9 +4a76088fd649351a870fc49932485df934e98fcb +aab08fb22ee1b493cc18a8d1d091d3e4f4b6dcdb +b9905c8f06c561e66f14a5f69a8d06c0ad2e8f54 +742ff4b9312b36d2674eaf6d855e6555bfdd14fc +fc5db16160067fc884f5129b53c2c2c30d97dbdf +a2807f038ef6628f886fe9b4618b1fea96224ff3 +0a9d4c144d150fbb78e66050fd9f73f40539eda2 +655a9afc9a891327cfebe359c66de3e30d9cf360 +7bcc1f03f75b4036eab05d8d4c7648ab05cf866a +43d9e056eb2f07736497d0a0043259af6a367693 +f5cfbf6a24b4c4ba8af9ae1f1f4ff46aa6ce4552 +c711733287d3eccee7dd8151b1efd3f990653ee8 +8bb3878d47836036a2b723edaaae44e6fc621e80 +8003f8bf07e2e49216ffefc3280b43c572a952d0 +c39611d5667d66d8d7a8c3b65a655d35a0c26f49 +83f5021e7cb6ac9cda65ddc009015405c2ba6b91 +a4bfae8e4411064653404a61aa384ea2f52d4eb3 +1e4094e0775d11a1dbea00968b083838a3eaa576 +c84ae49b820ee56263f6448cc5de6ce9c7da2254 +0203a9795266e20bf32a6be4c44ff14af42a25f6 +1ba3cddeea3bd00ff4ce337abbb00e289495d473 +8193e74ff88bbd1a9ee14ca9b9f51fd590e3351f +b2e29836799a526c17ae6b1c742ec03f43e5db88 +ccdfc4b8222abca3af87de4b794f00988e57d7d5 +ca1ed10fa8fbc1572986d9d9242fe3eee1ad091d +bde716a0c9f93b4098ff16c38238c05980ed0eed +979efc701912270022dca394c0aff138967caa1e +062e5cb286ab289f439d59feffaa519a4b0eb163 +6edb43c851e0857b37a91a2c33698527cac67c22 +6b64819c0842cc55a52da26fc2f5efcee3afd450 +9ee8084745df9b6d47f63f5c55a94cbb008a0a55 +b489ce43d5f601dfccc462be1bbc5cda68b10b95 +8ea067ddccc35e2a3d13886a130faf7278463114 +b0ef9814fec761540d73f6daa7175516573b7af1 +db5b9885b92887befb0aead9a276891e933b1dab +c0c462ee5c33bdb413c97fb80f3b391d6f65b1f5 +580876152d87fe08f5074027043ddd2c9bf81beb +fd81a63a5ceb38379736897482a5da2577554709 +a51cd91973af710bc8371aedfcf35e56da1ec5cb +56ca00299094832de60609416c67a8d9b1bbb4e5 +417623c1bc2b9830397d29c134c7eb15a4bbbdbb +1509c1bbf381516016d0615968479f2d004b643b +10733a018a1ea4439d6830d1ffab4b292d64856a +00efd58b1ff1a27c5acb2ac973eba5cf94cbd100 +8d7823d7fdb12fff24600591d8f392b0fae3d8dd +b7a8a16fea706aeef2d60f813b9bb247eab0fc84 +4ace920dc95a09e9fad4b075e51058ebfd3ea4f5 +6375695fc0c982071740b0e0a9a5b028426e24da +6088d3cda293fb3d723078247beaeb38ebf606de +961b363d3560726b20af48b298952831619737ab +d7144083a4b438e7e23e7669ab8fd72c3cf4da58 +b1728d32972d82df1d01fdcc4775eeb4d6573a66 +94574f004b1f1f4e1eb3de340d6d3c5786fce205 +e734c0bc62caf294cad80336a04ea201494ee749 +fd1b6917edd6a3d3f6c0f68b5b6cf39cd37d16af +c6b163a6b294dfeeac2617ac29e2d8ecfdfeb991 +6ac1f70c65fe8eb0dddff52247cd1a363c52bec9 +c94bb96e9f7ce59bc5fefe170b1971ee5d4ead0d +6e11f3cd67bb1274308914937edc0835280b2483 +63e4d5bd72c4cc101b9e733198d2a748e4cd3ed1 +077283537e93caf2e6bceae59abf607dbfe484dc +38416518c8759cfc7846a5cef4f77566d5d9e7fa +12195b88459060af3161694f43af8f99c1cd9afc +d2a9457c88976dcb594af8ad46f8841160171d7f +aaaf6638b7cacfd02fe56fc608103e91d5f9f849 +97caf9394a5fbba5eda7dc99e528ca32b4e460de +dd59e586376628ebd517f26dafbbdbe8d72eab89 +d8fea4d24eb4278414f03d525f095384a7debaba +f7534ac45eda041e4dfccb428f4d81e6e0f5b379 +947b54abbf33b9dbdb464f83716ddacd7af533f0 +d5b8755b6c064bb853aa489b6a4e7012c3012249 +4346fbe81275438f742aded116d0db71ec78094c +cce7528acaade5073d058b8eecbdcc0a9a54f818 +28bfb8cddf97bf58c7038416a7b4454773d60c5c +56eaa2e0d4071b067955269d908ff3b17de68957 +c4e0734961d29bb0671a8140f4c8b9721cee9420 +3712af28b18579be77414b98447b56e8db13f085 +2e5bbd0db301b6b7883318b08d779acd755f476c +4d05b316c5e25e624558ceda2c2a0aed9428f6ee +20d6656c4f77f294b5e9055da6b6aa169673b040 +a64da44ddc1cba77229ba024cac0948cb96a7676 +24ce813193ef19d10359b757642fd2dbfc8c48c6 +7ddbe3902e0dec4d2298b282813c17dd65e6e2ee +42c709f52c7f73c3eaf2e9793d1e5fdb84827869 +52403bd1c6c5c5f0d84869185bbc6964d1db90bb +3c0ad6d68991961e2a72422fa4f69ed70d4ae6ab +2bd977df8b6d3decfbe33f0c01ebfd5222787d77 +f46e60b785d2fa28b98438422cef6e89c369e902 +713ece1808b7762dd4413c871ef0093eba5886c4 +a860da86a8578ce07ee245c888e9ce90ea911f54 +b0be9f0d46f0462b66de13e5705330439af9695e +aa7a46b0ed6b6b33973157df3aace8257475ac83 +a6df7be1f065ea92bca2c2898712649061480a44 +a2f60eb85700f35125d6f6aa0d74d95191ff8cc0 +037ade5451edd788e9575b1b7555d2d00667c93b +a05abacd2f90d290b1f3f15ca200f6652bb393d3 +6d4b94dc4a9953ed6a7a1986f06a018ba2991b63 +e6cf8fab16928785e45b3e649645560c9ef58545 +3bb46478e4271d6327d0acac496324265b6931a7 +ca3c93a317678f0525f242eda9bba927a93de9b2 +c76dd4c447a533b624f8829299112af44f52b2c6 +84d000e07736e4d9c6da40ad6fd04c27f213b74e +1a015ee822d287cf564b016fb5fe57487a799f93 +8f2704aa0ecac935244e2f396474d37865d191a8 +d69bcaadaa5dffd0c2dd7fd91c933743d7fbbf53 +2b2c787636cfffd7760710933784be903d171b63 +4d8b034206326e307d4f4ae1720563effa2cf754 +4130f1a97b5be548ebad885c71f5fdfbdbe6086f +578d35837d7c3b43abd78b2d2d3699741093216c +19c11cbfdbff810d0bef2a019a78bf0e6d6b5c2e +400d89b7e350a3596b7fd1d6646201f002d7cbc3 +ea3f62b1dc17c3ddf3fecce1ed3263f19b5072d0 +90113a109933dd493232a9f30715aa9d944b39c8 +417623c1bc2b9830397d29c134c7eb15a4bbbdbb +1509c1bbf381516016d0615968479f2d004b643b +4a4df199566ea8107df3032889cdeafc1073bbb1 +8e0e25cd3e89c4d39d7c33c9813d5c578af00e98 +d03552d3ad07faecf8badaedb57a61099129909e +35ae5241adb11a210a19875b96127055ffd02330 +b3405a751674277f60d20393b20f0b096c28367b +22c89c9b0f6c205279dd2574b8d033b7ac385166 +c4d822855c7891414a0d67ea96da1d5b3233c338 +80f7da0261c6a02a9c4a9b9993834860078fd03e +2ed07e123f712b387c3a1dec40827fb0a9603f42 +eccbb14b7b9b78f9e41208eb749caf10f188a23d +cdc969e4d3920382bc124a67fd621c15f2d79e52 +f1037fc31ecbd1a5c185e8205695c11c1966acf4 +1fe522cdd333469d01c780508b9846f3a96fc839 +50621ac24aca1972e57759147e5f0ae963c17e7f +8f7b184405405c430314996ef3bf5212ea0fa612 +c8804e6fb90dc81b31b28d6299e21a3639a31854 +3368241b6a21495c72f6075cef64f34ef9230079 +4e6c57f14b0db349269a4f6707a7fb55f11075fe +d9ee1591b23e95d4e63436daa2de7556f6e345b9 +01318e26512002c782b3362cb436a27787749668 +068a56d79cd17df8e6914c870dfa6d44697cac07 +58e8241159616601da4f25cb3a84f20a118c5fa3 +7ff347dfa505f928698404921a3e9a331f883019 +a8aa822d8544351204a77874996f21f2d6871f8e +f269c779e262017846734f7daec144fc6ddc8cbc +fe59b380152ce90ef4bd3be75b9bf9b544f742dd +8fc6eaac1711a1210b468e72fafef1762166a380 +5bd2cd690bb6db367d442c2956a6e15092175eb7 +a05703536c1d6da3cbea8d40b78a1a862adac799 +118e798e01c89fcd73688d3fab1552475e92222d +02b9d7bf8a19a1ebd6ca219e5cff1537841fd155 +d1684e43cb5409f86119a6f0ba6b5c695e88981c +c8c200ffbc20c95e010d8cfc8980a56e7cdbc929 +499c4e9e00fb890d6178011d91d22383440e1a2d +6938fe0f6d3befd155cb05502377c97419103837 +32118fa2f419c7638544171df456d4edfc4043b7 +352801449ee088800a22a1d4ed23d1055f509e34 +baf009604e6998d28860292413a6d4d3106707e4 +386be16b8ba1e89ca5702880ce52f7990338a51e +4f562b0ab9dc44dececc7d6fd9368987f1bcf37d +1d6bea453ff09bcafde8258d6ce2c59fc55f9214 +0d52d545761b90dde29f71062562441f57ba844c +cf448184e0207f654868384a06f8e29dab5981f7 +fa87b0c81f5581f2f2d17a145a42f07227246bd1 +7be00244368fa71cdd95278ef3ad7a9aa58598cb +fd396dc16bcf077d6d3403269475241d2e1d167f +2b73326d9685d16167494d7f498c86dfd9cecbcc +8cbb116f18a245610a5a881cb36b0c8853b83b8e +6dc11202f78f60f213c62956f7949717f6170307 +d0178b9dd3358cc48c28b747a2e3085acaf0e2dc +dfe7b79a94b2018dcf7fb585b72abb1ab13d9688 +bac436433c8082bad6a032df72eb20251e76aeb8 +2af5c3ab3dd62cdb761f1ec19053d38eeaabdb12 +2a745da619c8d1be153aa2ee474f2d84dc8a483c +3920be3be6a7b13ffcefea79b89c9f71b76b2c98 +137537d31ad13efb9060f1ee1b8cf102ab0cfffd +66f41772d15b8b012a2d44c46ef105d27bf688e9 +72276fe228e1160316b32ae0ef4dfbc93607df29 +99b162a8aafb351393c0e01ae50606afb1cb3484 +88f944e0ae4d74e82f31116d26826059409da59e +9af4ef0f3fdda5da4d9d19ed5321fe0ee69976be +3fed1e5b9f07738525ebf88aa824b5e8bbaf77b7 +a3f1eeee549c9cba193158abb187b779ed193574 +f7f4790f977922505c437a657c63afff8e553676 +12291af54893a94909957b6085def5ee326e1071 +bb830379073fdbdf065a217016a4d6052fbc2d8b +75ae7a68c5652cfd678aaced0ee0517ce6cd550c +dc2f18d8e6624ebcfd056079d2b9889f66af144a +8e318974552e4a472d6d6a2693ff00be696072f0 +a4e190c237bf382fa5f2a6286222503f86c0df22 +98f5f8fce21218bad44b81278d5f0aa9fdbdf9f7 +c7431e4b69c93c13b33b0b4b7a505c70ee0d4455 +2ed07e123f712b387c3a1dec40827fb0a9603f42 +eccbb14b7b9b78f9e41208eb749caf10f188a23d +47139ebbd74eb8256a9bc59380c3ebbe4b9161a4 +69ccbbed36adc15861684226dbc3967f02e45a34 +53652e045227b8843e27c5385645172f5fe70746 +e17644e7611d45b8c350faa6df8b089d3e7813a8 +2dcb9f0bda8dcbbb803694e62914438709ca1fb9 +7e4189ec7661c52d388b60603302e61a5faca0ab +57b55e6ef6db2b8afe70df3ec63ef364a6c3b7bb +2b96caa8e67119236fe0c274532f1c779e20cd95 +e78eec0a8b813abdd3bd99ea0bfa914794db4bd3 +8b93706efedf8777807024482c0e75ae9b0c5a39 +d32997a4d9b5be6a820579812d6c15efb9f48bf5 +dfe7b79a94b2018dcf7fb585b72abb1ab13d9688 +bac436433c8082bad6a032df72eb20251e76aeb8 +51ca9077f177ce4a45915661e72aab5da90d9b91 +dae68c562061e6f2a13cdaab4bed9a62c098e143 +6ef61bf7206818bee8488706353d51a029506022 +fb436256a285f3e46320ef8724e4fac3823dd8f4 +feeb17ca0512d8f01e35cd0e7877eb5a7a352978 +875f7ae0d93a65ff6b2343285b46e61b721af343 +ca7a9f1bedebcd0161152ec6748807b5f94f14d3 +24ce813193ef19d10359b757642fd2dbfc8c48c6 +7ddbe3902e0dec4d2298b282813c17dd65e6e2ee +5cfa78ff554305bdcc7df79caa1b17a8e533983b +ed2ef8f0174350d384f01cf3d4cbc77de59fdfa9 +ee493fe283f50992879fe2301700bb362f3bd02f +cb32ee79ddc19464401808dbd5e01603fd97d010 +b9509806b71a5163395065d644717f9e4f2a6528 +86643e2ccc44b18bca5d57c0be5a2bdc31445c0c +c4e0734961d29bb0671a8140f4c8b9721cee9420 +3712af28b18579be77414b98447b56e8db13f085 +23c1da39d4f87a2598f2f13e0c10b9cd1f309918 +0cb4908c7c3642c782566c179cd33f2a4f788678 +fc869d9fd0e890e3eda0ccd401493b3cfe36a156 +7fb02652211168c83050fdc54cef8eb3a740e028 +20d6656c4f77f294b5e9055da6b6aa169673b040 +a64da44ddc1cba77229ba024cac0948cb96a7676 +be6a40b53fc142322395bf59f86f6cd046beaba3 +6fa2431721911edf5ca1f9d50c24cca162668c05 +b134af6081ac3966912be824aa89df24b688f90c +663c1bdec831757ef5bd18e36584f5f922dafbc5 +5464c6f30f4b9ab4576f17b9f31bffc41dffc22e +cf448184e0207f654868384a06f8e29dab5981f7 +326e268846fbac8e75f84745de805362c2363185 +a2fd0543fe9cfb63958ca8802bf1cc21e74350aa +02f91ca84bd78ea683b52568b0613c58763f134c +fa87b0c81f5581f2f2d17a145a42f07227246bd1 +4da0eb5b608675460a5599de883b51acb945f4bc +762478fb0783755523fd35c3e76f2bf71861e578 +a291334b7d6147a3ad3d54eb2d11965e56d73521 +d60f213462c55df8cbe8e36acf08ec874560bb73 +857622c14a39cfa112482e51af3d2b54b553ac64 +d7075b0fc87f611de635eab40f724e85ad1a9f72 +bca94187ec887219a0f92360ff9f8b35dd7fb84d +a05703536c1d6da3cbea8d40b78a1a862adac799 +b633f2e0b6bd3c9095097ade003c47994a61553b +5517c6426d05a75a2eb0c2bef2c5e84d81de1729 +24bb959190903a773f8789e575e2d33c879ae085 +118e798e01c89fcd73688d3fab1552475e92222d +8e318974552e4a472d6d6a2693ff00be696072f0 +a4e190c237bf382fa5f2a6286222503f86c0df22 +264c801525c2ec8ada0fe4ca701241a015966a7a +49601f0ced99dff60b577873323f459f4f5adb27 +8890f4a77ac26feebbe85fddebe89efefe95411a +585946f9ee9ae1116f7435b8bec4c6782112f840 +127e1c5d5ac9aef9a51c27ff061009dd5cbee356 +d052fb727b0520288ec6643b161fafeda93209cd +4a4df199566ea8107df3032889cdeafc1073bbb1 +8e0e25cd3e89c4d39d7c33c9813d5c578af00e98 +7b8a370f0cb359b983fa2ddadbecf9f61aa33146 +5f0c9b2d721952690f94a2c7c6b986da8ade7952 +391ff2ac9046ce0aa9ca620f37ced2fb9f65b493 +ab619037682a8267079770bd0b18e37fce6724c9 +f269c779e262017846734f7daec144fc6ddc8cbc +c4d822855c7891414a0d67ea96da1d5b3233c338 +80f7da0261c6a02a9c4a9b9993834860078fd03e +82f2efaa2e331876de4a74ff53b6de3a276fd6e3 +cdc969e4d3920382bc124a67fd621c15f2d79e52 +b15811121f367d04a3ac7a92a09f67e27b6d552d +b41bc60c96536846fb077e4b9fe68787d64ca232 +58deb6da6c2bb3a72b9f7154d8f823a4f32e3316 +f1037fc31ecbd1a5c185e8205695c11c1966acf4 +a167a8f6ea9b45bfd48ce8e2bd969b9f48b98bfd +2b73326d9685d16167494d7f498c86dfd9cecbcc +8cbb116f18a245610a5a881cb36b0c8853b83b8e +d9953bd3fc800b1c8971a8aa2ac2f033ee0aa065 +c809d74c7a80b407f80a0b8d2c939a4027d56efd +beb10f6515e6c9b6d6f9a64499da89418b931fa0 +82bef182db8f84cbe56a1df4efdd3a8debb8d0cf +d43692928372badd32c62d4053dd6ee1344bba40 +801204bfb07fee0c953ba4535abe88091ec47325 +de93ee5f732774a604f48432261c5dc05a946fc5 +7caebe0b7176d25393be019169ca84f2fc24b547 +17148e490ad59206bd052a9c0b4915bcdfec5166 +e3c31c6f936fc376d017ec1cc2e355613bd7fc5f +63a479d2ed1e6e1878edef12a86182d8916d7e12 +3b0ee00887e57f9e09ba048fbdc8ef7cf09934af +c5a302724bd9d34e20d84cbc353980ce128f9351 +12f2d5a8cf2c7d77443007b978d8a9868d206e5e +7f1dd4b383e39eb1d934f75a86bf05a10cd85baa +8de2aaa4bea07d8e42c4afa3a9596f620e530acd +9dcf2d2a11a11ea2cd0deeaaefadf0f89e11d775 +746b0d9ce63289c084e15aec92938fe7982f1ad3 +a79c0293dc63c6c82dfd15a20ee0005d867b2333 +4d7163b722e05ac266e79fcb1231e05583595a2c +ac9a2a597da5fa378a0b0abb4eb77f7a62ebd41b +930bbea0f399256f5128eb81092e43d0f897e034 +645791746e79b2f3118a0eca79dbbae6fa6191a4 +fb484633d7aba3da1567d717ff4a4dbc79a4eb9e +da6244b48f6f1eccc9c21179f61cfd0a244e923f +1549f7ae4dd388f58cd0df457fe0d4cbdf371da0 +1b087654e2239d22e59ceea5b386b34e766e6843 +5bc1f3aa8f8beb6593a90fdef01a6171a46410f1 +6827322d9802937defcc8deb55946d0cd1f81874 +326d45c8eb39455fd22535e046ce93a4df70b6ab +3502dc0d2cdedb25940a10ebb6478286db1ceca8 +5e8892bf53634101c1efe46c9434ff8cdc0be82d +69ccbbed36adc15861684226dbc3967f02e45a34 +165d19806b39d125d5910b4302c4810a86b9416c +37c251f941adb5dd40f75bf554773ba23ddc2694 +0dce73e53721d64fa64f24ad79fbabc7825c4963 +1c1e8915b173d438f5fae7371bcc7836611307d2 +826b49d4adc0a57e7a3c9ef11d97198c3b3e15ad +e7058e1aa29e3f7937b9f35bf7580bc22622e4ef +ddd295f68851cf9e2c433c6f5b07b024f1c669f7 +0ff12ea0318d083d3a7cde42ce5ce8f416d2fc84 +7e2e2f2df8c01330f39e6a61f652062cf8e09dff +bd78a1058ac9c9b420009a5163cda729b9ce9cfb +3f18b7de0d2a27ba5b8b174cb9c8373cbef6053e +13c2e41300898027689e574aaf7fede08d8b88fa +14aa1ee8561953307b650caaa57eb89aac740c34 +a92ff82ec95460aef72fb5268430433986c8fc4e +a46a8944af0c3d077e66a748a8ceb4dc65ad97ad +87a589c2fc505c301766551163adc374d125375f +9df681150de94c9413a937874392e1c61ca7fee6 +912ca4281a44c51a8dca18808c5efd25233493ed +89ac7f7ba77fcd2393ac62201c2ef46bd3f6a8d2 +34c77170c098e829c7a2d1e00e3bbb3f42b47373 +cf81c3bd7861ca8e3567f0162434a3d7cfa4c059 +7fd90165e7478b034ddb45aa3db2eb8a00ce4036 +3226f192eda643b84805e528eaafd71fc89bf6c0 +8faa17baa69c5e8aa217e572bfc559490f77a113 +58e8241159616601da4f25cb3a84f20a118c5fa3 +ab9d521e1d88d656c3b9226f4065217eed9414d3 +3e4b4acf9f747c10912c1b5731df0b0be05a4b9d +1c3407726079190f7b4513ddff854b4110396f36 +9186a3747ac9150c1f22e309a758eab1e1d4716c +074d0881423783677eafb643e5337e856c06f4ca +0da2ca590f32f1f8fb4b8dddaa32e3101731bc17 +e9aa2c103a71b86cb4c902b4ab226cf48b8cce42 +9206d28d699b093f1f21ec9850d0b5e1c12965ce +45003492570044cd7e119d1c3c06345dbf3f47f6 +3769c7ea810bcb8238b881eecd204c9f71a59502 +46c2dc39ef7eaea68030a613558635d4bba07eb9 +f7534ac45eda041e4dfccb428f4d81e6e0f5b379 +d27da47f05141f358e5b044c9b604ca14250624e +66c53697a1c9e56b3899735b1502ec035862d211 +a43d58594f59ee1bd83040276e9e2d199656fd04 +a740b28290bd2a2c978cff4844a708334d9a5f68 +8d458f5a3980431a0428f30cedc34eedcf272ec6 +3dccb730ee6c6a73f08bb540fbfd5f83d6e0bd39 +54f2cd35194aac7320aed073362b54ce3535917f +1ebae7b1fa10b1e57168c7650099fe6ca85cc536 +3c834576aa91c21c407b6ac15d762952eaf5ea6e +e207071f71b050cb3c1762b93dd4513da8890ed6 +c7fe2d0e2a8ad7f625c75b3c8c32137107f676bc +82aeea0fc1ed0a5a8d64568fc0c4ae2e7baa2137 +8f249e8e923cbf7d756e0e9f2fd2a994e5a54dd6 +20c160a4cb7b095e310f3b35ce00ca73dafe4503 +152b03e5788842393ff89973c42bb820946cdfb5 +232dbb548fab2844d4e076bb944ec5f2c05044c7 +a172ed0972964dea6578bb0ac9a1a69ecdf983f3 +febc302f3f7495c651495fa2b5175d7ac581508e +bdaa926f4c084a4dce01a6ec6c1fdfa0718772ea +f14a4b2182660ddfa7c22f4698f0d75a19f3ac84 +634778d63b41a799978e5a34dbdd9fb1bce0a0d5 +260e07189e327c1a027d35eebf04e6e2623eaf9d +6025e6e883bad414ed34f2f71af70b4d72bf3e36 +3c0ad6d68991961e2a72422fa4f69ed70d4ae6ab +2bd977df8b6d3decfbe33f0c01ebfd5222787d77 +827b6db70630cdc4c6296440faac9d4ca66725e4 +f7d6bd4b1796b8f01581d84843ecb6849a93ffa5 +b5f8a3d03fd20f47ae73f8b5f249e90e8aecd91b +4ed9706eb17fd600681eede6b2c6dd8a90dda538 +b18c27d6d8a9b26a1d038774030428d00eb5c078 +68eb07c273a29bf6bb4babbdc35fb107d5c553a6 +939cf7e129f56d802ba0efc2f17fa7318ae801f1 +4d0cb054b355c4d217d31271b12082f49d8ad6d1 +83057bc03c4b565d6bd2e5ab33cdb984c3b9cd31 +2162dcc8661b3e3be39e85e2e0e4f0969f20059d +ac80debb5e053a31f3898dce585dc118bc6df8d5 +65616d2c62e13b0e9bda03e41812a00a49936a2d +aedd0cb02d12cea2ebe54a7cfff9c53e4ac73c1f +8ecb8d3840f6ee3df830e46d1c8c2a27f084edf5 +8ecb8d3840f6ee3df830e46d1c8c2a27f084edf5 +d37b857c055ae661e417f282fa97e3bb80063cb0 +8b054bebe1c61143e224e68f3986b6fca586a5df +eca0b96f28afa764abad40d26f322a5748c7ef08 +02f4e9b5ac7a9a6923c64ae3deee0c7e27f37781 +0fd5cc3b6fe4992098139b901baf53182a4578b1 +32cd7b58640e3fc4322ac09435669b16da2a9852 diff --git a/README.md b/README.md index fa98a616f..33d222253 100644 --- a/README.md +++ b/README.md @@ -359,6 +359,7 @@ stopwords = [ Refer to the default [gitleaks config](https://github.com/zricethezav/gitleaks/blob/master/config/gitleaks.toml) for examples or follow the [contributing guidelines](https://github.com/zricethezav/gitleaks/blob/master/README.md). ### Additional Configuration +#### gitleaks:allow If you are knowingly committing a test secret that gitleaks will catch you can add a `gitleaks:allow` comment to that line which will instruct gitleaks to ignore that secret. Ex: ``` @@ -367,6 +368,9 @@ class CustomClass: ``` +#### .gitleaksignore +You can ignore specific findings by creating a `.gitleaksignore` file at the root of your repo. In release v8.10.0 Gitleaks added a `Fingerprint` value to the Gitleaks report. Each leak, or finding, has a Fingerprint that uniquely identifies a secret. Add this fingerprint to the `.gitleaksignore` file to ignore that specific secret. See Gitleaks' [.gitleaksignore](https://github.com/zricethezav/gitleaks/blob/master/.gitleaksignore) for an example. + ## Secured by Jit diff --git a/cmd/detect.go b/cmd/detect.go index 43782be90..6bbdb39f1 100644 --- a/cmd/detect.go +++ b/cmd/detect.go @@ -71,6 +71,11 @@ func runDetect(cmd *cobra.Command, args []string) { log.Fatal().Err(err) } + // check for a .gitleaksignore file + if info, err := os.Stat(filepath.Join(source, ".gitleaksignore")); !os.IsNotExist(err) && !info.IsDir() { + detector.AddGitleaksIgnore(filepath.Join(source, ".gitleaksignore")) + } + // set exit code exitCode, err := cmd.Flags().GetInt("exit-code") if err != nil { diff --git a/detect/detect.go b/detect/detect.go index 2d3f8dc1d..213699ffd 100644 --- a/detect/detect.go +++ b/detect/detect.go @@ -1,6 +1,7 @@ package detect import ( + "bufio" "context" "fmt" "os" @@ -64,6 +65,9 @@ type Detector struct { // prefilter is a ahocorasick struct used for doing efficient string // matching given a set of words (keywords from the rules in the config) prefilter ahocorasick.AhoCorasick + + // gitleaksIgnore + gitleaksIgnore map[string]bool } // Fragment contains the data to be scanned @@ -96,11 +100,12 @@ func NewDetector(cfg config.Config) *Detector { }) return &Detector{ - commitMap: make(map[string]bool), - findingMutex: &sync.Mutex{}, - findings: make([]report.Finding, 0), - Config: cfg, - prefilter: builder.Build(cfg.Keywords), + commitMap: make(map[string]bool), + gitleaksIgnore: make(map[string]bool), + findingMutex: &sync.Mutex{}, + findings: make([]report.Finding, 0), + Config: cfg, + prefilter: builder.Build(cfg.Keywords), } } @@ -123,6 +128,23 @@ func NewDetectorDefaultConfig() (*Detector, error) { return NewDetector(cfg), nil } +func (d *Detector) AddGitleaksIgnore(gitleaksIgnorePath string) error { + log.Debug().Msg("found .gitleaksignore file") + file, err := os.Open(gitleaksIgnorePath) + + if err != nil { + return err + } + + defer file.Close() + scanner := bufio.NewScanner(file) + + for scanner.Scan() { + d.gitleaksIgnore[scanner.Text()] = true + } + return nil +} + // DetectBytes scans the given bytes and returns a list of findings func (d *Detector) DetectBytes(content []byte) []report.Finding { return d.DetectString(string(content)) @@ -428,6 +450,13 @@ func (d *Detector) Detect(fragment Fragment) []report.Finding { // addFinding synchronously adds a finding to the findings slice func (d *Detector) addFinding(finding report.Finding) { + // check if we should ignore this finding + if _, ok := d.gitleaksIgnore[finding.Fingerprint]; ok { + log.Debug().Msgf("ignoring finding with Fingerprint %s", + finding.Fingerprint) + return + } + d.findingMutex.Lock() d.findings = append(d.findings, finding) if d.Verbose { diff --git a/detect/detect_test.go b/detect/detect_test.go index f630fdf5d..c89dbc599 100644 --- a/detect/detect_test.go +++ b/detect/detect_test.go @@ -367,6 +367,7 @@ func TestFromGit(t *testing.T) { RuleID: "aws-access-key", Tags: []string{"key", "AWS"}, Entropy: 3.0841837, + Fingerprint: "d0ce473c3c9f6934e8d274604cf9ceae63700f03", }, { Description: "AWS Access Key", @@ -385,6 +386,7 @@ func TestFromGit(t *testing.T) { RuleID: "aws-access-key", Tags: []string{"key", "AWS"}, Entropy: 3.0841837, + Fingerprint: "df8d271fa20b928dfb12353cc16ddf9934225cb7", }, }, }, @@ -410,6 +412,7 @@ func TestFromGit(t *testing.T) { RuleID: "aws-access-key", Tags: []string{"key", "AWS"}, Entropy: 3.0841837, + Fingerprint: "df8d271fa20b928dfb12353cc16ddf9934225cb7", }, }, }, diff --git a/detect/utils.go b/detect/utils.go index 115c104e2..8490677a3 100644 --- a/detect/utils.go +++ b/detect/utils.go @@ -1,6 +1,7 @@ package detect import ( + "crypto/sha1" "encoding/json" "fmt" "math" @@ -21,6 +22,11 @@ func augmentGitFinding(finding report.Finding, textFragment *gitdiff.TextFragmen finding.EndLine += int(textFragment.NewPosition) } + // generate finding hash + h := sha1.New() + h.Write([]byte(fmt.Sprintf("%s:%s:%s:%d", finding.Commit, finding.File, finding.RuleID, finding.StartLine))) + finding.Fingerprint = fmt.Sprintf("%x", h.Sum(nil)) + if f.PatchHeader != nil { finding.Commit = f.PatchHeader.SHA finding.Message = f.PatchHeader.Message() diff --git a/report/csv.go b/report/csv.go index 7cbbd8366..e36cbaa2d 100644 --- a/report/csv.go +++ b/report/csv.go @@ -26,6 +26,7 @@ func writeCsv(f []Finding, w io.WriteCloser) error { "Message", "Date", "Email", + "Fingerprint", }) if err != nil { return err @@ -44,6 +45,7 @@ func writeCsv(f []Finding, w io.WriteCloser) error { f.Message, f.Date, f.Email, + f.Fingerprint, }) if err != nil { return err diff --git a/report/csv_test.go b/report/csv_test.go index 9f6f64533..c4dd4ec70 100644 --- a/report/csv_test.go +++ b/report/csv_test.go @@ -32,6 +32,7 @@ func TestWriteCSV(t *testing.T) { Author: "John Doe", Email: "johndoe@gmail.com", Date: "10-19-2003", + Fingerprint: "fingerprint", }, }}, { diff --git a/report/finding.go b/report/finding.go index e5f680234..0c74861a4 100644 --- a/report/finding.go +++ b/report/finding.go @@ -35,6 +35,9 @@ type Finding struct { // Rule is the name of the rule that was matched RuleID string + + // unique identifer + Fingerprint string } // Redact removes sensitive information from a finding. diff --git a/testdata/expected/report/csv_simple.csv b/testdata/expected/report/csv_simple.csv index e1481abd2..ca3cb0a02 100644 --- a/testdata/expected/report/csv_simple.csv +++ b/testdata/expected/report/csv_simple.csv @@ -1,2 +1,2 @@ -RuleID,Commit,File,Secret,Match,StartLine,EndLine,StartColumn,EndColumn,Author,Message,Date,Email -test-rule,0000000000000000,auth.py,a secret,line containing secret,1,2,1,2,John Doe,opps,10-19-2003,johndoe@gmail.com +RuleID,Commit,File,Secret,Match,StartLine,EndLine,StartColumn,EndColumn,Author,Message,Date,Email,Fingerprint +test-rule,0000000000000000,auth.py,a secret,line containing secret,1,2,1,2,John Doe,opps,10-19-2003,johndoe@gmail.com,fingerprint diff --git a/testdata/expected/report/json_simple.json b/testdata/expected/report/json_simple.json index 052131ba3..9d0a521ba 100644 --- a/testdata/expected/report/json_simple.json +++ b/testdata/expected/report/json_simple.json @@ -15,6 +15,7 @@ "Date": "10-19-2003", "Message": "opps", "Tags": [], - "RuleID": "test-rule" + "RuleID": "test-rule", + "Fingerprint": "" } ]