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

socket pnpm add / socket yarn add scan the alias name instead of the aliased package

Đang mở Phù hợp với người mới
#1,655 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

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

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
85/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
node.js, typescript
Lĩnh vực
cli, security

Hướng nghiên cứu

Đọc src/utils/npm-spec.mts và hàm safeParseNpmSpec; nó thiếu một nhánh alias và sử dụng kết quả từ npm-package-arg. Thêm xử lý cho kiểu 'alias' sử dụng subSpec để trả về gói và phiên bản thực. Xác minh với SOCKET_CLI_DEBUG=1 socket pnpm add my-lodash@npm:[email protected] rằng pkg:npm/[email protected] được gửi.

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

Mô tả

The shadow pnpm and yarn wrappers check packages with the Socket API before they install them. For an npm alias spec, the check looks up the alias name instead of the package that gets installed.

safeParseNpmSpec in src/utils/npm-spec.mts reads name and version from the npm-package-arg result. For an alias, npm-package-arg returns type: 'alias', sets name to the alias, and puts the real package in subSpec. The function has no branch for alias, so it returns the alias name with no version.

Command argument PURL sent for scanning Package installed
my-lodash@npm:[email protected] pkg:npm/my-lodash [email protected]
node-types@npm:@types/[email protected] pkg:npm/node-types @types/[email protected]

As a result, the installed package never gets checked. If an unrelated package has the alias name, its alerts are reported instead. socket yarn install has the same problem with aliased package.json dependencies such as "my-lodash": "npm:lodash@^4", because it builds name@version from each entry and passes the result to the same function.

Steps to reproduce

  1. Run SOCKET_CLI_DEBUG=1 socket pnpm add my-lodash@npm:[email protected].
  2. Check the packagePurls debug output.

Expected result

pkg:npm/[email protected]

Actual result

pkg:npm/my-lodash

Version

v1.x branch at 766b1e6 / [email protected].

Ngôn ngữ chính
TypeScript
Star
336
Fork
72
Merge trung bình
8 giờ 18 phút
Pull request đã merge (30 ngày)
70

Chuẩn bị môi trường

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 SocketDev/socket-cli

Tất cả issue của SocketDev/socket-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.