Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Generate command should respect file name safety conventions.

Đang mở
#25,282 1 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
angular, typescript
Lĩnh vực
cli

Hướng nghiên cứu

Bắt đầu tại điểm vào của lệnh generate trong Angular CLI và tái hiện tên component được báo cáo kết thúc bằng cd... Theo dõi cách tên đó trở thành một đường dẫn, sau đó xác minh rằng các tên không an toàn được xử lý mà không tạo ra một thư mục không thể phân giải; issue hoàn tất khi bản tái hiện tối thiểu không còn tạo ra đường dẫn có vấn đề.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

area: @angular-devkit/schematics freq1: low severity2: inconvenient type: bug/fix
Command

generate

Is this a regression?
  • Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was

No response

Description

Long story short is that the Angular CLI generate or g command is capable of doing some illegal and difficult to reverse file operations.

Longer version: I was going to create a component this morning to make building PrimeNG p-tables simpler and more dynamic. At the time I started, what I was thinking of was specific to a set of tables I intended to use in an administrative context, so I navigated to something like /src/modules/sales/costing-tool/components/templates and typed "ng g c admin-table". 

Before I hit enter, I thought about it and decided that rather than creating a module and specific use component that I'd rather make a general use component for generating p-tables dynamically & that it belonged in a shared module rather than a feature module. I thought I'd already deleted the CLI command out of the terminal so without looking I typed cd.. and hit enter. Which was the beginning of a 2+ hour headache that ended up costing me 2 days of work and which potentially could've cost me all the work I've done since May 5. 

So the command I effectively entered was "ng g c admin-tablecd..", and what happened is that the CLI was able to somehow dodge the OS level naming safety conventions & it created a folder named admin-tablecd.., which caused there to be an unresolvable reference in my project structure and made it unloadable and unbuildable. And there was nothing I could do to delete the offending folder. I tried deleting it through the UI, using DOS commands, using WSL commands including rmdir with the -rf flag, nothing would get rid of it, even after a reboot. I had just about resolved myself to having to clone my latest remote to a new local repo which would've set me back to the 5th when I tried rmdir with the "\?\c:\path\to\bad\directory" syntax which finally worked.

I think that optimally the generate command should respect naming safety conventions, or minimally provide a complimentary command to remove generated components.

Minimal Reproduction

Via the CLI, generate a component with a name that ends in a directory traversal operator, i.e. new-componentcd..

Exception or Error
The system cannot find the file or directory specified
Your Environment
Angular:

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1502.4
@angular-devkit/core         15.2.4
@angular-devkit/schematics   15.2.4
@schematics/angular          15.2.4
Anything else relevant?

Can't think of anything.

Ngôn ngữ chính
TypeScript
Star
27k
Fork
11.8k
Merge trung bình
17 giờ 25 phút
Pull request đã merge (30 ngày)
183

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của angular/angular-cli

Tất cả issue của angular/angular-cli

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.