-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support unpkg features #456
Conversation
No dependency changes detected. Learn more about Socket for GitHub ↗︎ 👍 No new dependency issues detected in pull request Bot CommandsTo ignore an alert, reply with a comment starting with Pull request alert summary
|
Codecov Report
@@ Coverage Diff @@
## master #456 +/- ##
==========================================
+ Coverage 97.45% 97.51% +0.06%
==========================================
Files 160 166 +6
Lines 14780 15360 +580
Branches 1891 1993 +102
==========================================
+ Hits 14404 14979 +575
- Misses 376 381 +5
|
app/port/controller/package/ShowPackageVersionFileController.ts
Outdated
Show resolved
Hide resolved
app/port/controller/package/ShowPackageVersionFileController.ts
Outdated
Show resolved
Hide resolved
unpkg 相关接口只用于产物预览吗?如果配置了 contentType, 是否需要处理 CDN 盗链的情况 另外我们是否需要加上开关配置,只对白名单内的包支持预览能力,减少内容安全风险。 |
内容问题通过内容扫描服务来解决。我加个开关,默认开启。 |
app/port/controller/package/ShowPackageVersionFileController.ts
Outdated
Show resolved
Hide resolved
app/port/controller/package/ShowPackageVersionFileController.ts
Outdated
Show resolved
Hide resolved
WARN: include sql change closes #452
还差一个主动同步,在 package add event 里面加上。 |
ctx.vary(this.config.cnpmcore.cdnVaryHeader); | ||
const [ scope, name ] = getScopeAndName(fullname); | ||
const packageVersion = await this.#getPackageVersion(ctx, fullname, scope, name, versionOrTag); | ||
ctx.set('cache-control', META_CACHE_CONTROL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这些感觉应该封装一下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
headers 设置?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该是所有的,把 http 协议相关的拆分开。比如提供 HttpRequest 和 HttpResponse 对象注入,其实 koa 本身也是分开的,只是都注入到 ctx 了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@killagu 又来了,看看怎么搞。
[skip ci] ## [3.19.0](v3.18.0...v3.19.0) (2023-05-05) ### Features * support unpkg features ([#456](#456)) ([8ec081a](8ec081a))
🎉 This PR is included in version 3.19.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
所有文件信息都存在 package_version_files 这张表会不会有性能问题? |
@baxtergu 用目前云上的数据库,单表没有上限。 |
https://help.aliyun.com/document_detail/41708.html 是用的 RDS for MySQL 么? |
@baxtergu 是的,目前单表早就超过这个限制了。 |
@fengmk2 了解了,感谢解答。 |
@@ -87,6 +87,8 @@ export default (appInfo: EggAppConfig) => { | |||
syncNotFound: false, | |||
// redirect to source registry when package not found | |||
redirectNotFound: true, | |||
// enable unpkg features, https://github.com/cnpm/cnpmcore/issues/452 | |||
enableUnpkg: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fengmk2 这块是不是还需要进一步支持下黑白名单机制,用在 cnpmcore 内网部署时,避免安全合规问题
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
黑名单现在是服用的,blocks 的都不会被 unpkg 解析。
白名单太多,三方库没有特别好的思路。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
指的是企业内网部署的场景,一个包要发布到 unpkg,需要审核,避免一些包被无意识的情况下泄漏出去,有种 ssrf 攻击的感觉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那可能先关闭 enableUnpkg 比较合适。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉可以有个 middleware,然后读取某个远程配置,判断包名
WARN: include sql change
😄 Follow unpkg router
😄 Auto sync files after package version add
closes #452