Subscription status response validators omit validation of data and nested lastTransactions
还没有人认领这个 Issue。
- #467 来自 @Shubham-Padkonde —— 已关闭,未合并
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 84/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- api
调研方向
先在构建 package 后检查 dist/models/StatusResponse.js、dist/models/SubscriptionGroupIdentifierItem.js 和 dist/models/LastTransactionsItem.js 中的 validators。跟踪可选数组和嵌套 validators 的处理方式,然后为无效的数组类型、格式错误的嵌套条目以及有效的省略字段或嵌套字段添加回归覆盖。完成的标准是:无效的嵌套响应返回 false,而有效响应和省略的可选字段仍被接受。
由索引模型根据 Issue 内容生成。
描述
Description
StatusResponseValidator checks environment, bundleId and appAppleId, but never validates data, which is declared as SubscriptionGroupIdentifierItem[].
There is a second gap in the nested model: SubscriptionGroupIdentifierItemValidator checks only subscriptionGroupIdentifier and never validates lastTransactions, which is declared as LastTransactionsItem[].
Consequently, the response validator accepts a non-array data value, malformed subscription-group entries and malformed transaction entries. Connecting StatusResponseValidator to the existing subscription-group validator alone would not fully address the problem, because that validator also omits its nested array.
Reproduction
From the repository root, after building the package:
const {
StatusResponseValidator,
} = require('./dist/models/StatusResponse.js');
const {
SubscriptionGroupIdentifierItemValidator,
} = require('./dist/models/SubscriptionGroupIdentifierItem.js');
const {
LastTransactionsItemValidator,
} = require('./dist/models/LastTransactionsItem.js');
const responseValidator = new StatusResponseValidator();
const groupValidator = new SubscriptionGroupIdentifierItemValidator();
const transactionValidator = new LastTransactionsItemValidator();
console.log(responseValidator.validate({ data: 'not-an-array' }));
// true
console.log(groupValidator.validate({ lastTransactions: 'not-an-array' }));
// true
const invalidTransaction = { signedTransactionInfo: 123 };
console.log(responseValidator.validate({
data: [{
subscriptionGroupIdentifier: '123',
lastTransactions: [invalidTransaction],
}],
}));
// true
console.log(transactionValidator.validate(invalidTransaction));
// false
Expected behavior
When present, data must be an array of valid subscription-group items. Within each group, lastTransactions, when present, must be an array of valid transaction items. Invalid nested values should cause validation of the containing response to return false.
Omitted optional fields should remain accepted, consistent with the current model definitions.
Impact
AppStoreServerAPIClient.getAllSubscriptionStatuses uses StatusResponseValidator. Its runtime validation therefore does not enforce the declared structure of the subscription data returned to callers. Downstream code may receive incompatible values despite a successful client validation result.
This concerns structural validation of the API response. Cryptographic verification of the signed transaction and renewal payloads remains a separate operation.
Suggested change
- In
StatusResponseValidator, check that a presentdatavalue is an array and validate each entry withSubscriptionGroupIdentifierItemValidator. - In
SubscriptionGroupIdentifierItemValidator, check that a presentlastTransactionsvalue is an array and validate each entry withLastTransactionsItemValidator. - Add regression coverage for invalid array types, invalid nested fields and valid nested responses.
- 主要语言
- TypeScript
- 星标
- 388
- 派生
- 88
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apple/app-store-server-library-node 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
-
NotificationHistoryResponseValidator uses the response validator for history items and accepts malformed item fields可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
-
难度 3/5 1-2 天 新手友好度 54/100
-
Cloudflare Workers (nodejs_compat): SignedDataVerifier passes with online checks; two non-crypto blockers remain可能已有人在做 @vishalhabib99 于 4 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 32/100
apple/app-store-server-library-node#476 · 1 条评论 · 1 个 reaction ·
-
Abort OCSP requests when the response times out可能已有人在做 @TorinAsakura 于 71 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 68/100
查看 apple/app-store-server-library-node 的全部 Issue
相似的 Issue
-
bug priority: low role: BE stage: now
难度 2/5 1-3 小时 新手友好度 86/100
ahmadrosid/nakama#2594 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
milind-soni/OpenMausBot#6495 ·
维护者通常 1 天内回复
-
Navigating the session tree adds the branch's prompts to Up-arrow history again可能已有人在做 @acmerfight 今天认领。 未关闭untriaged
难度 2/5 1-3 小时 新手友好度 68/100
earendil-works/pi#12279 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
approved documentation
难度 1/5 1 小时以内 新手友好度 89/100
vitest-dev/vitest#12015 · 4 条评论 ·
维护者通常 1 天内回复