searchJobs

Prev Next

Classic/VPC 환경에서 이용 가능합니다.

네이버 클라우드 플랫폼 콘솔에서 사용자가 등록한 진단 리스트를 검색 유형 및 작업 상태와 같은 특정 진단 내역으로 필터링 조회하여 결과를 출력합니다.

요청

요청 형식을 설명합니다. 요청 형식은 다음과 같습니다.

메서드 URI
POST /search

요청 헤더

Web Security Checker에서 공통으로 사용하는 헤더에 대한 자세한 내용은 Web Security Checker 요청 헤더를 참조해 주십시오.

요청 바디

요청 바디에 대한 설명은 다음과 같습니다.

{
    "searchType": "url",
    "searchKeyword": "http://your-domain",
    "statusCode": null,
    "limit": 10,
    "page": 1
}
필드 타입 필수 여부 설명
searchType String Required 검색 유형
  • url | memo | 공백
    • url: searchKeywordncloud.com과 같이 도메인 또는 URI를 입력
    • memo: 작업 생성 시 입력한 메모 문자열을 searchKeyword에 입력
    • 공백: 전체 검색
searchKeyword String Required searchType에 대응하는 검색 키워드 지정
statusCode Integer Required 작업 상태 코드로 검색
  • null: 전체 검색
  • 2: 진단 대기
  • 3: 진단 진행 중
  • 4: 진단 완료
  • 5: 진단 실패
  • 12: URL 수집 대기
  • 13: URL 수집 진행 중
  • 14: URL 수집 완료
  • 15: URL 수집 실패
  • 91: 진단 취소
  • 92: 중지 중
  • 93: 작업 중지
limit Integer Required 리스트 한 페이지당 출력 항목 수
page Integer Required 리스트의 페이지 번호

요청 예시

요청 예시는 다음과 같습니다.

curl --location --request POST 'https://wsc.apigw.gov-ntruss.com/api/v1/jobs/search'
--header 'x-ncp-apigw-timestamp: {Timestamp}'
--header 'x-ncp-iam-access-key: {Access Key}'
--header 'x-ncp-apigw-signature-v2: {API Gateway Signature}'
--header 'Content-Type: application/json'
--data '{"searchType": "url",
"searchKeyword": "http://your-domain",
"statusCode": null,
"limit": 10,
"page": 1}'

응답

응답 형식을 설명합니다.

응답 바디

응답 바디에 대한 설명은 다음과 같습니다.

필드 타입 필수 여부 설명
total_cnt Integer - 총 작업 레코드 수
total_page_cnt Integer - 마지막 페이지
current_start_page Integer - 시작 페이지 번호(10개 단위)
current_end_page Integer - 마지막 페이지 번호(10개 단위)
record_data Array - 진단 목록
record_data[].instanceNo Integer - 작업의 식별 번호
record_data[].start_date Date - 진단 작업의 시작 시간
record_data[].end_date Date - 진단 작업의 종료 시간
record_data[].status String - 작업 상태
record_data[].progress Integer - 진단 진행률
record_data[].start_url String - 진단 작업 대상 URL
record_data[].crawl_cnt Integer - 크롤링 URL 수집 개수
record_data[].scan_cnt Integer - 취약점 개수
record_data[].memo String - 작업 메모
record_data[].result_button String - 작업 상태
  • report | cancel | terminate | expired | cause
    • report: 리포트 출력 가능 상태
    • cancel: 작업 취소 상태
    • terminate: 작업 중지 상태
    • expired: 기간 만료
    • cause: 작업 진행 중 오류 발생
record_data[].result_desc String - 작업 결과 상세 설명
  • 작업 오류 시 상세 출력
record_data[].rescan_button String - 재진단 가능 상태
  • possible | expired | null
    • possible: 재진단 가능
    • expired: 기간 만료로 재진단 불가
    • null: 재진단 불가
record_data[].slave_data Array -

응답 상태 코드

Web Security Checker API에서 공통으로 사용하는 오류 코드에 대한 자세한 내용은 Web Security Checker 공통 오류 코드를 참조해 주십시오.

응답 예시

응답 예시는 다음과 같습니다.

  • 조회 완료: 조회 정보가 있는 경우
{
    "returnCode": "0",
    "returnDesc": "Request Success",
    "returnMessage": "Success",
    "resources": {
        "total_cnt": 1,
        "total_page_cnt": 1,
        "current_start_page": 1,
        "current_end_page": 1,
        "record_data": [
            {
                "instanceNo": "1234567890",
                "start_date": "2024-07-08 13:12:03",
                "end_date": "2024-07-08 13:15:10",
                "status": "진단 완료",
                "progress": null,
                "start_url": "http://your-domain",
                "crawl_cnt": "1",
                "scan_cnt": "1",
                "memo": "샘플",
                "result_button": "report",
                "result_desc": "",
                "rescan_button": "possible",
                "slave_data": null
            }
        ]
    }
}
  • 조회 완료: 조회 정보가 없는 경우
{
    "returnCode": "0",
    "returnDesc": "Request Success",
    "returnMessage": "Success",
    "resources": {
        "total_cnt": 0,
        "total_page_cnt": 0,
        "current_start_page": 0,
        "current_end_page": 0,
        "record_data": null
    }
}

샘플 코드

make_signature 함수로 시그니처를 생성하여 요청 헤드를 생성한 후 입력한 요청 파라미터에 따라 특정 상태의 진단 리스트를 조회하여 응답 코드가 200인 경우 결과를 출력하는 샘플 코드는 다음과 같습니다.

import sys
import os
import hashlib
import hmac
import base64
import requests
import time
import json

def make_signature(method, uri, timestamp):

    access_key = "{accessKey}"  # access key id (from portal or sub account)
    secret_key = "{secretKey}"  # secret key (from portal or sub account)
    secret_key = bytes(secret_key, 'UTF-8')

    method = method
    uri = uri

    message = method + " " + uri + "\n" + timestamp + "\n" + access_key
    message = bytes(message, 'UTF-8')
    signingKey = base64.b64encode(hmac.new(secret_key, message, digestmod=hashlib.sha256).digest())
    return signingKey

timestamp = str(int(time.time() * 1000))

method = 'POST'
uri = '/api/v1/jobs/search'
payload = {
  "searchType": "url",
  "searchKeyword": "user-domain",
  "statusCode": None,
  "limit": 1,
  "page": 1
}

timestamp = str(int(time.time() * 1000))

signature = make_signature(method, uri, timestamp)

headers = {
    'x-ncp-apigw-signature-v2': signature.decode('utf-8'),
    'x-ncp-apigw-timestamp': timestamp,
    'x-ncp-iam-access-key': '{accessKey}', # access key id (from portal or sub account)
    'Content-Type': 'application/json'
}

response = requests.request(
    method,
    f"https://wsc.apigw.gov-ntruss.com{uri}",
    headers=headers,
    data=json.dumps(payload), # Json format required
)

if response.status_code == 200:
    print(response.text)
참고

샘플 코드는 Python3를 기반으로 작성했습니다. Java, Node.js 등 다른 언어로 작성한 샘플 코드는 API Gateway 사용 가이드의 API 호출을 참조해 주십시오.