Data-component channels crashes and log-sources returns an empty body when optional log sources are absent

未关闭 适合新手
#513 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
85/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
javascript
领域
api, backend

调研方向

从 app/controllers/data-components-controller.js 中的 channels 和 log-sources 处理器入手,然后查找这些投影现有的 REST 测试。添加针对字段缺失、后续修订中省略这些字段、字段已填充以及组件不存在的测试。完成标准是:两个投影在字段缺失时都返回 JSON [],同时保留字段已填充时的响应,以及组件不存在时的 HTTP 404。

由索引模型根据 Issue 内容生成。

描述

Verified on REST API 4.24.0, commit 69b37fe769e6abe7675d413451a8361aecc36bea.

Reproduction and impact

Create a valid data component with populated x_mitre_log_sources, then create a newer revision omitting that optional field. The write succeeds with HTTP 201 and ordinary component GET selects the new revision.

GET /api/data-components/COMPONENT_ID/channels
GET /api/data-components/COMPONENT_ID/log-sources
  • Channels returns HTTP 500 with body Server error..
  • Log-sources returns HTTP 200 with zero body bytes and no JSON content type.

Both populated projections work. Correlated REST logs confirm the channels exception twice:

TypeError: Cannot read properties of undefined (reading 'map')

Root cause and expected fix

The channels controller calls .map() on the missing value; the log-sources controller sends it directly.

Return HTTP 200 JSON [] from both projections when the field is absent, preserving populated responses and missing-component HTTP 404.

Omission is valid in REST, Mongoose and the version-matched ADM schema. A present STIX array requires at least one entry, so default the read projection without storing an invalid empty array.

Add REST tests for initially absent fields, later revisions omitting them, populated fields, and nonexistent components. Assert JSON array bodies explicitly.

主要语言
JavaScript
星标
56
派生
18
平均合并
19 小时 39 分钟
30 天内合并 PR
7

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

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

mitre-attack/attack-workbench-rest-api 的其他 Issue

查看 mitre-attack/attack-workbench-rest-api 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

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