> ## Documentation Index
> Fetch the complete documentation index at: https://docs.oasm.io/llms.txt
> Use this file to discover all available pages before exploring further.

# 쿼리 구조

> Attack Surface Query의 구성 요소: 배치, from, select, 관련 행, include, 응답 형태

## 배치

요청은 이름이 지정된 쿼리의 **배치**입니다.

```json theme={null}
{
  "window": { "since": "now-7d" },
  "queries": {
    "<name>": { "from": "<resource>", "...": "..." },
    "<another name>": { "from": "<resource>", "...": "..." }
  },
  "options": { "consistent": false, "mode": "interactive", "timezone": "UTC" }
}
```

**queries** `object` *required*

이름이 지정된 쿼리 1\~10개. 이름은 문자로 시작하고 문자, 숫자, `_`를 포함합니다(최대 64자). 결과는 같은 이름 아래로 반환됩니다.

**window** `object`

자체 기간을 지정하지 않은 모든 쿼리의 기본 시간 기간: `{ "since": "now-7d", "until": "now" }`. [시간 기간](https://docs.oasm.io/ko/attack-surface-query/filtering.md#time-windows)을 참고하세요.

**options.consistent** `boolean` (default: false)

배치의 모든 쿼리를 하나의 데이터베이스 스냅샷에서 차례로 실행합니다. 여러 쿼리의 수치가 정확히 맞아야 할 때(보고서) 사용하세요. 그렇지 않으면 쿼리는 병렬로 실행됩니다.

**options.mode** `string` (default: interactive)

`interactive`는 배치를 즉시 실행합니다. `report`는 훨씬 큰 한도의 백그라운드 작업으로 대기열에 넣습니다. [저장된 쿼리와 보고서](https://docs.oasm.io/ko/attack-surface-query/saved-queries-and-reports.md#report-mode)를 참고하세요.

**options.timezone** `string` (default: UTC)

시간 버킷(`day`, `week`…)을 나누는 기준이 되는 IANA 시간대. 예: `Asia/Ho_Chi_Minh`. [시간대](https://docs.oasm.io/ko/attack-surface-query/aggregations.md#time-zones)를 참고하세요.

> [!WARNING]
>
> 모든 객체는 엄격합니다. 어디에든 알 수 없는 키(`"selct"` 같은 오타나 `workspaceId`)가 있으면 무시되지 않고 오류가 됩니다. 워크스페이스는 항상 본문이 아니라 세션에서 가져옵니다.

## 쿼리

**from** `string` *required*

읽을 리소스: `targets`, `hosts`, `services`, `technologies`, `tls`, `urls`, `ips`, `dnsRecords`, `vulnerabilities`, `rollups`.

**select** `string[]`

반환할 필드. 생략하면 작은 기본 필드 세트를 반환합니다(`services`의 경우: `port`, `host.value`, `firstSeen`).

**include** `object`

각 행에 붙일 관련 행 목록. [include](#include-lists-of-related-rows)를 참고하세요.

**where** `object`

필터. [필터링](https://docs.oasm.io/ko/attack-surface-query/filtering.md)을 참고하세요.

**window** `object | null`

이 쿼리의 시간 기간. 배치의 기간을 덮어씁니다. `null`은 전체 기간을 뜻합니다.

**windowField** `string`

기간을 적용할 시간 필드. 기본값: 리소스의 `firstSeen`.

**groupBy / aggregate** `array / object`

쿼리를 집계로 바꿉니다. [집계와 그룹화](https://docs.oasm.io/ko/attack-surface-query/aggregations.md)를 참고하세요.

**having** `object`

집계 쿼리의 그룹을 그룹 키나 집계 이름으로 필터링합니다. [having](https://docs.oasm.io/ko/attack-surface-query/aggregations.md#having-filter-the-groups)을 참고하세요.

**fill** `boolean` (default: false)

빈 버킷을 포함해 기간의 모든 시간 버킷을 반환합니다. [빈 버킷 채우기](https://docs.oasm.io/ko/attack-surface-query/aggregations.md#filling-empty-buckets)를 참고하세요.

**orderBy** `object[]`

`{ "field", "dir": "asc" | "desc" }` 최대 세 개. 기본값: 최신순.

**limit** `number` (default: 50)

페이지당 행 수. 최댓값은 [페이징, 한도, 비용](https://docs.oasm.io/ko/attack-surface-query/paging-and-limits.md)을 참고하세요.

**cursor** `string`

이전 페이지의 `nextCursor`.

**withTotal** `boolean` (default: false)

일치하는 행 수인 `total`도 반환합니다(최대 10 000).

## select: 필드와 관련 행

필드는 리소스의 필드(`port`)이거나, 점 경로로 쓰는 **단일 관련 행**의 필드입니다. 서비스에는 호스트 하나, 대상 하나, 최신 HTTP 응답 하나가 있으므로 `services`에서는 다음이 모두 유효합니다.

```json theme={null}
{ "from": "services", "select": ["port", "host.value", "target.value", "http.title", "http.statusCode"] }
```

결과에는 관련 필드가 중첩되어 표시됩니다.

```json theme={null}
{
  "id": "53c80e50-…",
  "port": 443,
  "host": { "value": "api.example.com" },
  "target": { "value": "example.com" },
  "http": { "title": "API Gateway", "statusCode": 200 }
}
```

경로는 관련 행 두 개를 연결할 수 있습니다. `technologies` → `service` → `host`는 `service.host.value`가 됩니다.

> [!TIP]
>
> 존재하지 않는 관련 행은 null로 채운 객체가 아니라 `null`로 반환됩니다. `"http": null`은 서비스에 HTTP 응답이 없다는 뜻입니다.

## include: 관련 행 목록

호스트에는 서비스가 여러 개 있고, 서비스에는 기술과 URL이 여러 개 있습니다. 목록은 `select`에 넣을 수 없으므로 `include`로 붙입니다. 각 include는 그 자체로 작은 쿼리입니다.

```json theme={null}
{
  "from": "hosts",
  "select": ["value"],
  "limit": 20,
  "include": {
    "services": {
      "select": ["port", "http.title"],
      "limit": 10,
      "include": {
        "technologies": { "select": ["name", "version"], "limit": 5 }
      }
    }
  }
}
```

```json theme={null}
{
  "id": "1396ad91-…",
  "value": "api.example.com",
  "services": [
    { "id": "…", "port": 443, "http": { "title": "API Gateway" },
      "technologies": [ { "id": "…", "name": "nginx", "version": "1.25" } ] }
  ]
}
```

**include.\<list>.select** `string[]`

자식 행(과 그 관련 행)의 필드.

**include.\<list>.where** `object`

자식 행에 대한 필터. 일치하는 자식만 붙습니다. 부모 행은 이 필터로 걸러지지 않습니다(부모를 거르려면 부모의 `where`를 사용하세요).

**include.\<list>.orderBy** `object[]`

자식의 정렬 순서. 일부 필드만 목록을 정렬할 수 있습니다(예: `firstSeen`, 호스트의 서비스에서는 `port`). 나머지는 자연 순서를 유지합니다.

**include.\<list>.limit** `number` (default: 10)

부모 행당 자식 수(최대 50, AI 에이전트는 20).

**include.\<list>.include** `object`

중첩 목록. 최대 두 단계 깊이까지.

> [!WARNING]
>
> 각 include는 **모든 행마다** 자체 한도까지 가져옵니다. 호스트 200개 × 서비스 20개는 자식 행 4 000개입니다. `limit × include limit`를 작게 유지하거나, 필터를 사용해 자식 리소스를 직접 조회하세요([쿼리 조합하기](https://docs.oasm.io/ko/attack-surface-query/composing-queries.md) 참고).

### 리소스별 목록

| 리소스 | 단일 관련 행(점을 사용한 `select`) | 목록(`include` 또는 `where`) |
| - | - | - |
| `targets` | – | `hosts` |
| `hosts` | `target` | `services`, `ips`, `dnsRecords`, `vulnerabilities` |
| `services` | `host`, `target`, `http` | `technologies`, `tls`, `statusCodes`, `urls`, `tags` |
| `technologies`, `tls`, `urls` | `service` | – |
| `ips`, `dnsRecords` | `host` | – |
| `vulnerabilities` | `host`, `tool` | – |

## 기본 필드와 순서

| 리소스 | 기본 `select` | 기본 순서 |
| - | - | - |
| `targets` | `value`, `type`, `firstSeen` | 최신순 |
| `hosts` | `value`, `kind`, `firstSeen`, `target.value` | 최신순 |
| `services` | `port`, `host.value`, `firstSeen` | 최신순 |
| `technologies` | `name`, `version`, `service.host.value`, `service.port` | 최신순 |
| `tls` | `host`, `port`, `notAfter`, `issuerCn` | `notAfter` 오름차순(만료 임박 순) |
| `urls` | `url`, `firstSeen` | 최신순 |
| `ips` | `ip`, `host.value` | 최신순 |
| `dnsRecords` | `recordType`, `value`, `host.value` | 최신순 |
| `vulnerabilities` | `name`, `severity`, `host.value`, `firstSeen` | 최신순 |
| `rollups` | `metric`, `key`, `value` | `value` 내림차순 |

읽을 권한이 없는 기본 필드(예: `target.read` 없이 `target.value`)는 쿼리를 실패시키는 대신 제외됩니다.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.