Commit e3efe98
authored
fix: verify length and hashes of fetched bytes before parsing (#325)
* feat: add func to util for comparing raw bytes
Add BytesMatchLenAndHashes() to verify that fetched bytes match the
expected length and hashes.
This is useful to check data before parsing.
Signed-off-by: Joshua Lock <[email protected]>
* fix: verify snapshot's len and hashes before parsing
Signed-off-by: Joshua Lock <[email protected]>
* fix: verify targets' len and hashes before parsing
Signed-off-by: Joshua Lock <[email protected]>
* feat: export version comparison utility function
Signed-off-by: Joshua Lock <[email protected]>
* fix: only check version after parsing fetched ss and ts
We check the length and hashes of the fetched bytes before parsing them,
therefore once the data are parsed into a FileMeta we only need to check
against the expected version. The length and hashes checks are no longer
required at this point, as they have already been done.
Signed-off-by: Joshua Lock <[email protected]>
* fix: remove spurious length check
Signed-off-by: Joshua Lock <[email protected]>
* chore: test newly exported util functions
Add tests for newly exported functions in the util package:
* VersionEqual() - simple test of version number comparison
* BytesMatchLenAndHashes() - check function returns appropriate errors
when incorrect length, hashes, or both are passed
Signed-off-by: Joshua Lock <[email protected]>1 parent 439ce47 commit e3efe98
3 files changed
+125
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
674 | 674 | | |
675 | 675 | | |
676 | 676 | | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
677 | 682 | | |
678 | 683 | | |
679 | 684 | | |
680 | 685 | | |
681 | | - | |
682 | | - | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
683 | 689 | | |
684 | 690 | | |
| 691 | + | |
685 | 692 | | |
686 | 693 | | |
687 | 694 | | |
| |||
691 | 698 | | |
692 | 699 | | |
693 | 700 | | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
694 | 706 | | |
695 | 707 | | |
696 | 708 | | |
697 | 709 | | |
698 | | - | |
699 | | - | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
700 | 713 | | |
701 | 714 | | |
| 715 | + | |
702 | 716 | | |
703 | 717 | | |
704 | 718 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
89 | 115 | | |
90 | 116 | | |
91 | 117 | | |
| |||
102 | 128 | | |
103 | 129 | | |
104 | 130 | | |
105 | | - | |
| 131 | + | |
106 | 132 | | |
107 | 133 | | |
108 | 134 | | |
| |||
125 | 151 | | |
126 | 152 | | |
127 | 153 | | |
128 | | - | |
| 154 | + | |
129 | 155 | | |
130 | 156 | | |
131 | 157 | | |
| |||
149 | 175 | | |
150 | 176 | | |
151 | 177 | | |
152 | | - | |
| 178 | + | |
153 | 179 | | |
154 | 180 | | |
155 | 181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
| |||
195 | 198 | | |
196 | 199 | | |
197 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
0 commit comments