Commit 5ca584b
Validate assets against file map before serving (#1643)
Summary:
Pull Request resolved: #1643
Assets served via the `/assets/` endpoint were not being validated against Metro's file map. This meant that files excluded from the file map (via `blockList`, `.git`/`.hg` directories, etc.) could still be accessed through the asset serving endpoint, potentially exposing sensitive files.
This change adds file map validation to `getAsset()` by accepting an optional file existence check function. The Server now passes the DependencyGraph's `doesFileExist` method, which checks whether a file is present in the file map. Assets not in the file map are rejected with an appropriate error message.
This approach is more robust than checking blockList directly because the file map already applies all filtering logic (blockList patterns, VCS directories like `.git`/`.hg`, etc.), ensuring assets follow the same visibility rules as modules.
Reviewed By: robhogan
Differential Revision: D91128421
fbshipit-source-id: 0721599a609a54f02b2ff9f1474fe33726b8ee5e1 parent 947bac8 commit 5ca584b
6 files changed
Lines changed: 40 additions & 7 deletions
File tree
- docs
- packages/metro/src
- Server/__tests__
- __tests__
- node-haste
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
305 | | - | |
| 305 | + | |
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
| 285 | + | |
285 | 286 | | |
286 | 287 | | |
287 | 288 | | |
| |||
296 | 297 | | |
297 | 298 | | |
298 | 299 | | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
303 | 313 | | |
304 | 314 | | |
305 | 315 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
| 552 | + | |
552 | 553 | | |
553 | 554 | | |
554 | 555 | | |
555 | 556 | | |
556 | 557 | | |
557 | 558 | | |
| 559 | + | |
558 | 560 | | |
559 | 561 | | |
560 | 562 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
839 | 839 | | |
840 | 840 | | |
841 | 841 | | |
| 842 | + | |
842 | 843 | | |
843 | 844 | | |
844 | 845 | | |
| |||
856 | 857 | | |
857 | 858 | | |
858 | 859 | | |
| 860 | + | |
859 | 861 | | |
860 | 862 | | |
861 | 863 | | |
| |||
912 | 914 | | |
913 | 915 | | |
914 | 916 | | |
| 917 | + | |
915 | 918 | | |
916 | 919 | | |
917 | 920 | | |
| |||
936 | 939 | | |
937 | 940 | | |
938 | 941 | | |
| 942 | + | |
939 | 943 | | |
940 | 944 | | |
941 | 945 | | |
| |||
953 | 957 | | |
954 | 958 | | |
955 | 959 | | |
| 960 | + | |
956 | 961 | | |
957 | 962 | | |
958 | 963 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
153 | 169 | | |
154 | 170 | | |
155 | 171 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
| 181 | + | |
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| |||
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
366 | | - | |
| 366 | + | |
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
| |||
0 commit comments