Subscription status response validators omit validation of data and nested lastTransactions

未关闭
#450 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 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 present data value is an array and validate each entry with SubscriptionGroupIdentifierItemValidator.
  • In SubscriptionGroupIdentifierItemValidator, check that a present lastTransactions value is an array and validate each entry with LastTransactionsItemValidator.
  • 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 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apple/app-store-server-library-node 的其他 Issue

查看 apple/app-store-server-library-node 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。