Commit 113d05c
feat(storage): Implement robust path validation and structured skip reporting (#7546)
* feat: implement secure path validation for downloadManyFiles
- Adds protection against path traversal (../) using normalized path
resolution.
- Prevents Windows-style drive letter injection while allowing GCS
timestamps.
- Implements directory jail logic to ensure absolute-style paths are
relative to destination.
- Preserves backward compatibility by returning an augmented
DownloadResponse array.
- Automates recursive directory creation for validated nested files.
- Adds comprehensive 13-scenario test suite for edge-case parity.
* fix double-assignment
* feat(storage): secure path resolution and preserve result parity
- Implemented "jail" logic using path.resolve to prevent traversal.
- Neutralized leading slashes in GCS object names.
- Pre-allocated results array to maintain 1:1 input/output index parity.
- Added automatic recursive directory creation for nested local paths.
- Fixed prioritization of destination options in downloadManyFiles.
* feat(storage): prioritize drive check for Windows compatibility
- Reordered security checks to catch illegal drive letters before path
resolution.
- Fixed SkipReason mismatch (Illegal Character vs Path Traversal) on
Windows.
- Ensured absolute Windows paths are neutralized before traversal
validation.
* fix(storage): storage downloadManyFiles scoping and path traversal safety
Isolated async loop variables to fix path leakage, decoupled prefix
from destination logic, and added cross-platform traversal checks
for both forward and backslashes.
* fix(storage): ensure unique path resolution and cross-platform safety
Updated Parity Check tests with platform-conditional logic to handle
OS-specific backslash resolution.
* fix(storage): address logical escapes in stripPrefix
* fix: clarify downloadManyFiles docs
* build(storage): suppress punycode deprecation errors in tests
Node.js 22+ treats the deprecation of the built-in 'punycode' module
as a fatal error during the test load phase. Since this originates
deep within nested dependencies (node-fetch > whatwg-url), this
change adds --no-deprecation to NODE_OPTIONS in the test script
to allow the suite to run on modern Node versions.
* build(storage): fix CI test detection and Node 22 compatibility
- Added 'cross-env' to devDependencies for Windows compatibility.
- Used 'cross-env' to pass '--no-deprecation' to the test runner.
- This prevents 'punycode' deprecation warnings from crashing the suite.
---------
Co-authored-by: Gabe Pearhill <86282859+pearigee@users.noreply.github.com>1 parent 75c76e1 commit 113d05c
4 files changed
Lines changed: 356 additions & 37 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
| 133 | + | |
| 134 | + | |
134 | 135 | | |
135 | 136 | | |
136 | 137 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
399 | 415 | | |
400 | 416 | | |
401 | 417 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
540 | 542 | | |
541 | 543 | | |
542 | 544 | | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
543 | 573 | | |
544 | 574 | | |
545 | 575 | | |
| |||
554 | 584 | | |
555 | 585 | | |
556 | 586 | | |
| 587 | + | |
| 588 | + | |
557 | 589 | | |
558 | 590 | | |
559 | 591 | | |
560 | 592 | | |
561 | 593 | | |
562 | | - | |
| 594 | + | |
| 595 | + | |
563 | 596 | | |
564 | 597 | | |
565 | 598 | | |
| |||
570 | 603 | | |
571 | 604 | | |
572 | 605 | | |
573 | | - | |
| 606 | + | |
574 | 607 | | |
575 | 608 | | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
576 | 613 | | |
577 | 614 | | |
578 | 615 | | |
| |||
592 | 629 | | |
593 | 630 | | |
594 | 631 | | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | | - | |
| 632 | + | |
600 | 633 | | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
607 | 645 | | |
608 | | - | |
609 | | - | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
610 | 668 | | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
615 | 677 | | |
616 | 678 | | |
617 | 679 | | |
618 | 680 | | |
619 | 681 | | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
626 | 721 | | |
627 | | - | |
628 | | - | |
629 | | - | |
| 722 | + | |
630 | 723 | | |
631 | 724 | | |
632 | 725 | | |
633 | | - | |
| 726 | + | |
| 727 | + | |
634 | 728 | | |
635 | 729 | | |
636 | 730 | | |
| |||
0 commit comments