-
Notifications
You must be signed in to change notification settings - Fork 501
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support/fuzz: Add xdr.ClaimPredicate JSON fuzzing (#3181)
A bug in `xdr.ClaimPredicate.MarshalJSON` (#3179) stopped ingestion in testnet. I wrote a fuzzer to ensure there are no more bugs. Added files to separate `xdr/fuzz` package to add more fuzzers in the future.
- Loading branch information
Showing
104 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file added
BIN
+124 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/059ce73797da3779f67d67b27fbbe1586fb5af4c-11
Binary file not shown.
Binary file added
BIN
+76 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/06b5aa65dd57296c5d7d71c34e4458704c9d8504-24
Binary file not shown.
Binary file added
BIN
+220 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/070fdb451a68170438d23544e162edbe0c53831c-24
Binary file not shown.
Binary file added
BIN
+68 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/0738efae9b6af6dd2f5b47ee3670e79e120bf8ff-5
Binary file not shown.
Binary file added
BIN
+92 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/0c11486742bca82a11751928390f3c143964bae5-4
Binary file not shown.
Binary file added
BIN
+44 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/0c52a7776c7b6699bbb73b57fcd48c92d5861814-1
Binary file not shown.
Binary file added
BIN
+52 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/0e7786143ce4b5034c1df4f0bf398198b7880a06-1
Binary file not shown.
Binary file added
BIN
+124 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/0e92db53270df55314b1629bb2362d00be9ae485-27
Binary file not shown.
Binary file added
BIN
+64 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/17b83232cd0cb2405c3e44f22c1a449dd321bab1-14
Binary file not shown.
Binary file added
BIN
+60 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/18d6cfc1fee128a9ed89b45c644fefb1a67c557f-4
Binary file not shown.
Binary file added
BIN
+272 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/1dd0e81c3f135bbfcdf5e306727f1fdaa954c4b5-20
Binary file not shown.
Binary file added
BIN
+52 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/1ffd4bb29dbaf9a8b23a80410b7dcf6d160f20f5-5
Binary file not shown.
Binary file added
BIN
+68 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/22059050a2075418d91ab3d94cb5b5202dcb5449-10
Binary file not shown.
Binary file added
BIN
+180 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/22afe6d1107dc8421df2d27cf51c1e644c02c61c-18
Binary file not shown.
Binary file added
BIN
+108 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/23d671738a3514e6addb20280a0bd45d04991f35-9
Binary file not shown.
Binary file added
BIN
+92 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/24196ca658a9c921b531ee7000b268a21a630b9e-9
Binary file not shown.
Binary file added
BIN
+292 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/2ad5aa06b6a21b80102b70f792a6f5182b1e795e-26
Binary file not shown.
Binary file added
BIN
+436 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/2c4456e3a9606ff70b52b741d60629fc0aff6670-24
Binary file not shown.
Binary file added
BIN
+172 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/33081e04522f2adea4af265daeb32b9be88972ba-16
Binary file not shown.
Binary file added
BIN
+256 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/33ede038ddd6a6b2f2db89f2ead0338defbd68bb-26
Binary file not shown.
Binary file added
BIN
+192 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/34dabb7d96c82c2808d791c0267e28e79bfac2bf-19
Binary file not shown.
Binary file added
BIN
+444 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/3506b22eae67d429090fc709a72819b833c6d96f-25
Binary file not shown.
Binary file added
BIN
+52 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/35e0ed07d721971cb22d5957dee80f25ead2cb42-22
Binary file not shown.
Binary file added
BIN
+160 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/377545c22c2ee8e37810716409b46536e840f56b-20
Binary file not shown.
Binary file added
BIN
+188 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/3e9f514f89306765a02fba331f057ca66961dd71-17
Binary file not shown.
Binary file added
BIN
+44 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/3f2b6cbcae547826b84ba42a9e6ea0b1a3339aa4-2
Binary file not shown.
Binary file added
BIN
+164 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/3f6582b3dcb15d99dab3789e997aa26f721ecbfe-16
Binary file not shown.
Binary file added
BIN
+52 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/4079505f0bc61228e001bc6471699238dde274f4-4
Binary file not shown.
Binary file added
BIN
+132 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/48afcfe2230cea5d2d3ee438fa0b7a74e372d158-12
Binary file not shown.
Binary file added
BIN
+192 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/4f3bde9486d6faa2790e56aedf58b4ac44aec8b5-20
Binary file not shown.
Binary file added
BIN
+76 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/4fe56699612c2cf2ff3f386e7c555f560deadf9a-15
Binary file not shown.
Binary file added
BIN
+64 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/60b8e1cbf32b5ca3b1ec60572dab334951058d0b-6
Binary file not shown.
Binary file added
BIN
+32 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/61cb9be335a9ed20ab522fc29a6e6dfbcb33a601-1
Binary file not shown.
Binary file added
BIN
+112 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/63ab224880353a2b49f80077e9da722c18329ac1-10
Binary file not shown.
Binary file added
BIN
+112 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/658c4a6cc7e274ed79d0ce7ed12a2c7b8c57e601-5
Binary file not shown.
Binary file added
BIN
+60 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/6adde074d4fe03d42ba8caab1516c4ceb97da570-11
Binary file not shown.
Binary file added
BIN
+196 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/6b12dad633f25444a712e5fd0bb47ec718950a18-20
Binary file not shown.
Binary file added
BIN
+180 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/6cd24a62b01b2c0e4dcc1304817ca6700054b339-21
Binary file not shown.
Binary file added
BIN
+44 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/76ac82e6a9d81c206c98f8305978f3ceb003ef29-2
Binary file not shown.
Binary file added
BIN
+188 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/7704823d2993cac4543740727aadf0da46f0b187-19
Binary file not shown.
Binary file added
BIN
+52 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/78eb7d11840d3521ebdf34aa850c275d1f48bae8-12
Binary file not shown.
Binary file added
BIN
+28 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/7ff2c71aacf7b64291948dfb49369e5d1fee5e1c-2
Binary file not shown.
Binary file added
BIN
+52 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/802c4d37a41acc0a65a47dd9260578db8a91c7b0-2
Binary file not shown.
Binary file added
BIN
+140 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/80bce1575cf091d64032193bf508ef39b9a2c929-13
Binary file not shown.
Binary file added
BIN
+60 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/8167706299d763d2680aafb67be0c1de500bd577-1
Binary file not shown.
Binary file added
BIN
+100 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/836ccf6afc61a555e6c77db43e9972e14e018db3-17
Binary file not shown.
Binary file added
BIN
+52 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/8415b311a622e944074e28ca77d538f483201a43-3
Binary file not shown.
Binary file added
BIN
+52 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/8700a406939d1a113038c778808c81c32dc3bc28-1
Binary file not shown.
Binary file added
BIN
+44 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/8997d68a77b10c3c9ec4196b33e64224b3241266-2
Binary file not shown.
Binary file added
BIN
+196 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/8b3e6618aa03e9c7959cfd5a68095cb4d6a203df-20
Binary file not shown.
Binary file added
BIN
+64 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/8b9538724414e6d819239a7c01199398fab43ffc-3
Binary file not shown.
Binary file added
BIN
+4 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/9069ca78e7450a285173431b3e52c5c25299e473-1
Binary file not shown.
Binary file added
BIN
+72 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/958cc6437a39b63f7396b0a71d04007b88c6379b-7
Binary file not shown.
Binary file added
BIN
+44 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/959ed41ac6a90cd2ebc4795df6ddd40ea0d75b0f-2
Binary file not shown.
Binary file added
BIN
+244 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/9a18ed489961b6bd472665166ae1b92fadb4a30d-25
Binary file not shown.
Binary file added
BIN
+44 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/a01a7ff06434fa1552a81f30078b392e6d2bfad1-4
Binary file not shown.
Binary file added
BIN
+64 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/a46d5ed7d68b26e1c5d9c1b88d657dafd2205150-23
Binary file not shown.
Binary file added
BIN
+88 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/a7473f2a9f6d6c330457bf2de9d5969a55d0aee3-16
Binary file not shown.
Binary file added
BIN
+112 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/a751ccd38c35877231ba5493bfc2616870c2988e-24
Binary file not shown.
Binary file added
BIN
+44 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/a9d519b73acfc6693baa94caf8d3775d1b5c2e4d-3
Binary file not shown.
Binary file added
BIN
+136 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/aaa626f320812eb78a7ef9b957db9e00792c2ae6-25
Binary file not shown.
Binary file added
BIN
+148 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/ab8767081fee98bd3c608822c63599d9bb4cd7f0-15
Binary file not shown.
Binary file added
BIN
+140 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/abdc9928a9e1d7dc324eba5e7bd9be3d3f648a58-14
Binary file not shown.
Binary file added
BIN
+48 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/ac8f325e3a178437989e9fb6d577d8b3ec57cfd8-9
Binary file not shown.
Binary file added
BIN
+116 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/ae48c762a25dc2b03889d5830768edd235ec5b9e-10
Binary file not shown.
Binary file added
BIN
+124 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/b1a3550eaa19cc0fee2e869c5e126f433910d1d3-12
Binary file not shown.
Binary file added
BIN
+188 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/b20ec8a5c170be3a45ebb6d7736ef7e2450bcfc8-19
Binary file not shown.
Binary file added
BIN
+52 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/b283d6eafb57f10081d075a1e513297d0f003dda-4
Binary file not shown.
Binary file added
BIN
+72 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/b2af21ff16013174e8b940aeea46a5d2b7ebe959-3
Binary file not shown.
Binary file added
BIN
+276 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/b43d6499a479a144d48743aceab226ae04b084b3-27
Binary file not shown.
Binary file added
BIN
+44 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/b975870c79205eb51bb870470dc43a2247a840b4-2
Binary file not shown.
Binary file added
BIN
+52 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/ba38988d5c5dcc1ac3a71cd384361208fe07b52b-3
Binary file not shown.
Binary file added
BIN
+348 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/ba66c7f545d45a2f9e3a0ccdf3c890d599be0c04-23
Binary file not shown.
Binary file added
BIN
+64 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/bdc41f8d992fb63574a3502310f8da8fa2f46ecb-6
Binary file not shown.
Binary file added
BIN
+136 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/c0113ad49c1ab5cb58850b98f057361b51a07de9-19
Binary file not shown.
Binary file added
BIN
+64 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/c04c37d97e7d5f40e778a9f4f2798e79d67b2894-13
Binary file not shown.
Binary file added
BIN
+100 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/c3e528e0864bdeabc3a493347d081458107d6d02-8
Binary file not shown.
Binary file added
BIN
+72 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/c8e6898a08dcd50eb9d4277f52b5a1316363b1ce-8
Binary file not shown.
Binary file added
BIN
+76 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/cd9e58d3d455ad5a8dbe295c15bcc497ad0a5b3f-6
Binary file not shown.
Binary file added
BIN
+44 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/d1c5c02b37cee617709474c716cff28931a83f0a-1
Binary file not shown.
Binary file added
BIN
+52 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/d1c92868d562107bef8080a1e36abb5118cd6c1f-1
Binary file not shown.
Binary file added
BIN
+92 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/d47aadd63b71c1edf2560bd7790b6ece114ac150-4
Binary file not shown.
Binary file added
BIN
+92 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/d4e6caed58ca3f001ee3f9b719e72f48af941e69-8
Binary file not shown.
Binary file added
BIN
+88 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/dd2292f040e7417fd33bffef779136045e3e42e9-8
Binary file not shown.
Binary file added
BIN
+280 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/e1e0b62f78224847064adfb1db88db5c2ad7314f-22
Binary file not shown.
Binary file added
BIN
+52 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/e496e6bcb958104db803f6987f7463e64dd03c36-3
Binary file not shown.
Binary file added
BIN
+148 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/e6d28f2def888dd7b4e3e7bb0602a9a54032fc25-14
Binary file not shown.
Binary file added
BIN
+172 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/e9ae6ca39d51bd4198dc8b4f2ed429dd7464a1b7-15
Binary file not shown.
Binary file added
BIN
+280 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/ea5ef46f0ad1b2f1477437d6a8fea4a05bf589f9-21
Binary file not shown.
Binary file added
BIN
+112 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/ec7ef371ebfc7964bd80d7783b5e4eb0f614b9f2-18
Binary file not shown.
Binary file added
BIN
+172 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/ed23eb5f747659b11a5505b08e56624399351eb3-16
Binary file not shown.
Binary file added
BIN
+44 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/efad3ce838161e85a374929a9c0fd4d51812cc5f-2
Binary file not shown.
Binary file added
BIN
+84 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/f4e16e4477ecc1f88f51319373564404a1e9b03d-7
Binary file not shown.
Binary file added
BIN
+40 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/f54b8d6090a285885734d804129213715c3c5b55-10
Binary file not shown.
Binary file added
BIN
+60 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/f54d55cac405aed2c99ca12e5f630db204f46b67-2
Binary file not shown.
Binary file added
BIN
+68 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/f76bac376810acce74267a853b664a0a29d47d2b-5
Binary file not shown.
Binary file added
BIN
+64 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/f816b4e064d14656872cadca92ecb1f5179a6319-5
Binary file not shown.
Binary file added
BIN
+52 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/fb1c8df7fa2faac955b0e03fbc7423030d6ab8ae-1
Binary file not shown.
Binary file added
BIN
+92 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/fb4933de8b968e1cda99b1d7d8dfb600d60123ce-7
Binary file not shown.
Binary file added
BIN
+196 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/fbfab2089beccd80677b39f984d4a2e1151000e4-18
Binary file not shown.
Binary file added
BIN
+60 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/fd447488be54b05d69fa33e39e3754eb7b34a5ba-5
Binary file not shown.
Binary file added
BIN
+68 Bytes
xdr/fuzz/jsonclaimpredicate/corpus/fef930fcbbe7b532642eb9bed98dd04d6bbff761-11
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// +build gofuzz | ||
|
||
package jsonclaimpredicate | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
|
||
"github.com/stellar/go/xdr" | ||
) | ||
|
||
// Fuzz is go-fuzz function for fuzzing xdr.ClaimPredicate JSON | ||
// marshaller and unmarshaller. | ||
func Fuzz(data []byte) int { | ||
// Ignore malformed ClaimPredicate | ||
var p xdr.ClaimPredicate | ||
err := xdr.SafeUnmarshal(data, &p) | ||
if err != nil { | ||
return -1 | ||
} | ||
|
||
// Ignore invalid predicates: (and/or length != 2, nil not) | ||
if !validate(p) { | ||
return -1 | ||
} | ||
|
||
j, err := json.Marshal(p) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
var p2 xdr.ClaimPredicate | ||
err = json.Unmarshal(j, &p2) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
j2, err := json.Marshal(p2) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
if !bytes.Equal(j, j2) { | ||
panic("not equal " + string(j) + " " + string(j2)) | ||
} | ||
|
||
return 1 | ||
} | ||
|
||
func validate(p xdr.ClaimPredicate) bool { | ||
switch p.Type { | ||
case xdr.ClaimPredicateTypeClaimPredicateUnconditional: | ||
return true | ||
case xdr.ClaimPredicateTypeClaimPredicateAnd: | ||
and := *p.AndPredicates | ||
if len(and) != 2 { | ||
return false | ||
} | ||
return validate(and[0]) && validate(and[1]) | ||
case xdr.ClaimPredicateTypeClaimPredicateOr: | ||
or := *p.OrPredicates | ||
if len(or) != 2 { | ||
return false | ||
} | ||
return validate(or[0]) && validate(or[1]) | ||
case xdr.ClaimPredicateTypeClaimPredicateNot: | ||
if *p.NotPredicate == nil { | ||
return false | ||
} | ||
return validate(**p.NotPredicate) | ||
case xdr.ClaimPredicateTypeClaimPredicateBeforeAbsoluteTime: | ||
return *p.AbsBefore >= 0 | ||
case xdr.ClaimPredicateTypeClaimPredicateBeforeRelativeTime: | ||
return *p.RelBefore >= 0 | ||
} | ||
|
||
panic("Invalid type") | ||
} |