Skip to content

Commit bd61a82

Browse files
committed
1 parent c610f18 commit bd61a82

23 files changed

+1068
-337
lines changed
Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,43 @@
11
{
2-
"description": "Array type",
3-
"documents": [
2+
"description": "Array",
3+
"bson_type": "0x04",
4+
"test_key": "a",
5+
"valid": [
46
{
5-
"decoded": {
6-
"a": []
7-
},
8-
"encoded": "0D000000046100050000000000"
9-
},
7+
"description": "Empty",
8+
"bson": "0D000000046100050000000000",
9+
"extjson": "{\"a\" : []}"
10+
},
1011
{
11-
"decoded": {
12-
"a": [
13-
10
14-
]
15-
},
16-
"encoded": "140000000461000C0000001030000A0000000000"
17-
},
12+
"description": "Single Element Array",
13+
"bson": "140000000461000C0000001030000A0000000000",
14+
"extjson": "{\"a\" : [10]}"
15+
},
1816
{
19-
"decodeOnly": true,
20-
"decoded": {
21-
"a": [
22-
10
23-
]
24-
},
25-
"encoded": "130000000461000B00000010000A0000000000"
26-
},
17+
"description": "Single Element Array with index set incorrectly",
18+
"bson": "130000000461000B00000010000A0000000000",
19+
"canonical_bson": "140000000461000C0000001030000A0000000000",
20+
"extjson": "{\"a\" : [10]}"
21+
},
2722
{
28-
"decodeOnly": true,
29-
"decoded": {
30-
"a": [
31-
10
32-
]
33-
},
34-
"encoded": "150000000461000D000000106162000A0000000000"
23+
"description": "Single Element Array with index set incorrectly",
24+
"bson": "150000000461000D000000106162000A0000000000",
25+
"canonical_bson": "140000000461000C0000001030000A0000000000",
26+
"extjson": "{\"a\" : [10]}"
27+
}
28+
],
29+
"decodeErrors": [
30+
{
31+
"description": "Array length too long: eats outer terminator",
32+
"bson": "140000000461000D0000001030000A0000000000"
33+
},
34+
{
35+
"description": "Array length too short: leaks terminator",
36+
"bson": "140000000461000B0000001030000A0000000000"
37+
},
38+
{
39+
"description": "Invalid Array: bad string length in field",
40+
"bson": "1A00000004666F6F00100000000230000500000062617A000000"
3541
}
3642
]
3743
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"description": "Binary type",
3+
"bson_type": "0x05",
4+
"test_key": "x",
5+
"valid": [
6+
{
7+
"description": "subtype 0x00 (Zero-length)",
8+
"bson": "0D000000057800000000000000",
9+
"extjson": "{\"x\" : {\"$binary\" : \"\", \"$type\" : \"00\"}}"
10+
},
11+
{
12+
"description": "subtype 0x00",
13+
"bson": "0F0000000578000200000000FFFF00",
14+
"extjson": "{\"x\" : {\"$binary\" : \"//8=\", \"$type\" : \"00\"}}"
15+
},
16+
{
17+
"description": "subtype 0x01",
18+
"bson": "0F0000000578000200000001FFFF00",
19+
"extjson": "{\"x\" : {\"$binary\" : \"//8=\", \"$type\" : \"01\"}}"
20+
},
21+
{
22+
"description": "subtype 0x02",
23+
"bson": "13000000057800060000000202000000ffff00",
24+
"extjson": "{\"x\" : {\"$binary\" : \"//8=\", \"$type\" : \"02\"}}"
25+
},
26+
{
27+
"description": "subtype 0x03",
28+
"bson": "1D000000057800100000000373FFD26444B34C6990E8E7D1DFC035D400",
29+
"extjson": "{\"x\" : {\"$binary\" : \"c//SZESzTGmQ6OfR38A11A==\", \"$type\" : \"03\"}}"
30+
},
31+
{
32+
"description": "subtype 0x04",
33+
"bson": "1D000000057800100000000473FFD26444B34C6990E8E7D1DFC035D400",
34+
"extjson": "{\"x\" : {\"$binary\" : \"c//SZESzTGmQ6OfR38A11A==\", \"$type\" : \"04\"}}"
35+
},
36+
{
37+
"description": "subtype 0x05",
38+
"bson": "1D000000057800100000000573FFD26444B34C6990E8E7D1DFC035D400",
39+
"extjson": "{\"x\" : {\"$binary\" : \"c//SZESzTGmQ6OfR38A11A==\", \"$type\" : \"05\"}}"
40+
},
41+
{
42+
"description": "subtype 0x80",
43+
"bson": "0F0000000578000200000080FFFF00",
44+
"extjson": "{\"x\" : {\"$binary\" : \"//8=\", \"$type\" : \"80\"}}"
45+
}
46+
],
47+
"decodeErrors": [
48+
{
49+
"description": "Length longer than document",
50+
"bson": "1D000000057800FF0000000573FFD26444B34C6990E8E7D1DFC035D400"
51+
},
52+
{
53+
"description": "Negative length",
54+
"bson": "0D000000057800FFFFFFFF0000"
55+
},
56+
{
57+
"description": "subtype 0x02 length too long ",
58+
"bson": "13000000057800060000000203000000FFFF00"
59+
},
60+
{
61+
"description": "subtype 0x02 length too short",
62+
"bson": "13000000057800060000000201000000FFFF00"
63+
},
64+
{
65+
"description": "subtype 0x02 length negative one",
66+
"bson": "130000000578000600000002FFFFFFFFFFFF00"
67+
}
68+
]
69+
}
Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
{
2-
"description": "Boolean type",
3-
"documents": [
2+
"description": "Boolean",
3+
"bson_type": "0x08",
4+
"test_key": "b",
5+
"valid": [
46
{
5-
"decoded": {
6-
"b": true
7-
},
8-
"encoded": "090000000862000100"
9-
},
7+
"description": "True",
8+
"bson": "090000000862000100",
9+
"extjson": "{\"b\" : true}"
10+
},
1011
{
11-
"decoded": {
12-
"b": false
13-
},
14-
"encoded": "090000000862000000"
12+
"description": "False",
13+
"bson": "090000000862000000",
14+
"extjson": "{\"b\" : false}"
15+
}
16+
],
17+
"decodeErrors": [
18+
{
19+
"description": "Invalid boolean value of 2",
20+
"bson": "090000000862000200"
21+
},
22+
{
23+
"description": "Invalid boolean value of -1",
24+
"bson": "09000000086200FF00"
1525
}
1626
]
1727
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"description": "Javascript Code",
3+
"bson_type": "0x0D",
4+
"test_key": "a",
5+
"valid": [
6+
{
7+
"description": "Empty string",
8+
"bson": "0D0000000D6100010000000000",
9+
"extjson": "{\"a\" : {\"$code\" : \"\"}}"
10+
},
11+
{
12+
"description": "Single character",
13+
"bson": "0E0000000D610002000000620000",
14+
"extjson": "{\"a\" : {\"$code\" : \"b\"}}"
15+
},
16+
{
17+
"description": "Multi-character",
18+
"bson": "190000000D61000D0000006162616261626162616261620000",
19+
"extjson": "{\"a\" : {\"$code\" : \"abababababab\"}}"
20+
},
21+
{
22+
"description": "two-byte UTF-8 (\u00e9)",
23+
"bson": "190000000261000D000000C3A9C3A9C3A9C3A9C3A9C3A90000",
24+
"extjson": "{\"a\" : \"\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\"}"
25+
},
26+
{
27+
"description": "three-byte UTF-8 (\u2606)",
28+
"bson": "190000000261000D000000E29886E29886E29886E298860000",
29+
"extjson": "{\"a\" : \"\\u2606\\u2606\\u2606\\u2606\"}"
30+
},
31+
{
32+
"description": "Embedded nulls",
33+
"bson": "190000000261000D0000006162006261620062616261620000",
34+
"extjson": "{\"a\" : \"ab\\u0000bab\\u0000babab\"}"
35+
}
36+
],
37+
"decodeErrors": [
38+
{
39+
"description": "bad code string length: 0 (but no 0x00 either)",
40+
"bson": "0C0000000261000000000000"
41+
},
42+
{
43+
"description": "bad code string length: -1",
44+
"bson": "0C000000026100FFFFFFFF00"
45+
},
46+
{
47+
"description": "bad code string length: eats terminator",
48+
"bson": "10000000026100050000006200620000"
49+
},
50+
{
51+
"description": "bad code string length: longer than rest of document",
52+
"bson": "120000000200FFFFFF00666F6F6261720000"
53+
},
54+
{
55+
"description": "code string is not null-terminated",
56+
"bson": "1000000002610004000000616263FF00"
57+
},
58+
{
59+
"description": "empty code string, but extra null",
60+
"bson": "0E00000002610001000000000000"
61+
},
62+
{
63+
"description": "invalid UTF-8",
64+
"bson": "0E00000002610002000000E90000"
65+
}
66+
]
67+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"description": "Javascript Code with Scope",
3+
"bson_type": "0x0F",
4+
"test_key": "a",
5+
"valid": [
6+
{
7+
"description": "Empty code string, empty scope",
8+
"bson": "160000000F61000E0000000100000000050000000000",
9+
"extjson": "{\"a\" : {\"$code\" : \"\", \"$scope\" : {}}}"
10+
},
11+
{
12+
"description": "Non-empty code string, empty scope",
13+
"bson": "1A0000000F610012000000050000006162636400050000000000",
14+
"extjson": "{\"a\" : {\"$code\" : \"abcd\", \"$scope\" : {}}}"
15+
},
16+
{
17+
"description": "Empty code string, non-empty scope",
18+
"bson": "1D0000000F61001500000001000000000C000000107800010000000000",
19+
"extjson": "{\"a\" : {\"$code\" : \"\", \"$scope\" : {\"x\" : 1}}}"
20+
},
21+
{
22+
"description": "Non-empty code string and non-empty scope",
23+
"bson": "210000000F6100190000000500000061626364000C000000107800010000000000",
24+
"extjson": "{\"a\" : {\"$code\" : \"abcd\", \"$scope\" : {\"x\" : 1}}}"
25+
},
26+
{
27+
"description": "Unicode and embedded null in code string, empty scope",
28+
"bson": "1A0000000F61001200000005000000C3A9006400050000000000",
29+
"extjson": "{\"a\" : {\"$code\" : \"\\u00e9\\u0000d\", \"$scope\" : {}}}"
30+
}
31+
],
32+
"decodeErrors": [
33+
{
34+
"description": "field length zero",
35+
"bson": "280000000F6100000000000500000061626364001300000010780001000000107900010000000000"
36+
},
37+
{
38+
"description": "field length negative",
39+
"bson": "280000000F6100FFFFFFFF0500000061626364001300000010780001000000107900010000000000"
40+
},
41+
{
42+
"description": "field length too short (less than minimum size)",
43+
"bson": "160000000F61000D0000000100000000050000000000"
44+
},
45+
{
46+
"description": "field length too short (truncates scope)",
47+
"bson": "280000000F61001F0000000500000061626364001300000010780001000000107900010000000000"
48+
},
49+
{
50+
"description": "field length too long (clips outer doc)",
51+
"bson": "280000000F6100210000000500000061626364001300000010780001000000107900010000000000"
52+
},
53+
{
54+
"description": "field length too long (longer than outer doc)",
55+
"bson": "280000000F6100FF0000000500000061626364001300000010780001000000107900010000000000"
56+
},
57+
{
58+
"description": "bad code string: length too short",
59+
"bson": "280000000F6100200000000400000061626364001300000010780001000000107900010000000000"
60+
},
61+
{
62+
"description": "bad code string: length too long (clips scope)",
63+
"bson": "280000000F6100200000000600000061626364001300000010780001000000107900010000000000"
64+
},
65+
{
66+
"description": "bad code string: negative length",
67+
"bson": "280000000F610020000000FFFFFFFF61626364001300000010780001000000107900010000000000"
68+
},
69+
{
70+
"description": "bad code string: length longer than field",
71+
"bson": "280000000F610020000000FF00000061626364001300000010780001000000107900010000000000"
72+
},
73+
{
74+
"description": "bad scope doc (field has bad string length)",
75+
"bson": "1C0000000F001500000001000000000C000000020000000000000000"
76+
}
77+
]
78+
}

0 commit comments

Comments
 (0)