VulnCheck 플랫폼은 API와 포털에서 공유되는 토큰 시스템을 사용합니다. 이를 통해 동일한 토큰으로 API와 웹 포털을 오가며 사용할 수 있으며, 한 곳에서 토큰을 관리할 수 있습니다. 이 가이드는 토큰 생성 및 사용 방법을 안내합니다.
VulnCheck 플랫폼에 API 호출을 시작하려면 계정에 토큰을 발급해야 합니다. 방법은 다음과 같습니다:
30일 동안 사용하지 않은 토큰은 만료됩니다.
VulnCheck는 세 가지 방식의 토큰 전달을 지원합니다.
Authorization: Bearer insert_token_here 형식의 사용자 지정 헤더로 추가합니다.
curl --request GET \
--url https://api.vulncheck.com/v3/index/initial-access \
--header 'Accept: application/json' \
--header 'Authorization: Bearer insert_token_here'
client := &http.Client{}
var responseJSON interface{}
request, _ := http.NewRequest("GET", "https://api.vulncheck.com/v3/index/initial-access", nil)
request.Header.Set("Accept", "application/json")
request.Header.Set("Authorization", "Bearer " + "insert_token_here")
response, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
_ := json.NewDecoder(response.Body).Decode(responseJSON)
import requests
url = "https://api.vulncheck.com/v3/index/initial-access"
headers = {
"accept": "application/json",
"authorization": "Bearer {token}"
}
params = {}
response = requests.get(url, headers=headers, params=params)
print(response.json())
API 토큰을 GET/URL 파라미터로 전달할 수 있습니다. 이를 통해 브라우저에서 토큰을 쉽게 테스트하고 엔드포인트를 탐색할 수 있습니다.
curl --request GET \
--url https://api.vulncheck.com/v3/index/initial-access \
--header 'Accept: application/json' \
--url-query token=insert_token_here
client := &http.Client{}
var responseJSON interface{}
request, _ := http.NewRequest("GET", "https://api.vulncheck.com/v3/index/initial-access", nil)
request.Header.Set("Accept", "application/json")
params := url.Values{}
params.Add("token", "insert_token_here")
response, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
_ := json.NewDecoder(response.Body).Decode(responseJSON)
import requests
url = "https://api.vulncheck.com/v3/index/initial-access"
headers = {
"accept": "application/json"
}
params = {
"token": "insert_token_here"
}
response = requests.get(url, headers=headers, params=params)
print(response.json())
토큰을 쿠키로 전달할 수도 있습니다. 실제로 웹 포털이 이 방식으로 동작하며, 토큰을 완전히 제어하면서 포털을 통해 API에 액세스할 수 있습니다.
curl --request GET \
--url https://api.vulncheck.com/v3/index/initial-access \
--header 'Accept: application/json' \
--cookie "token=insert_token_here"
client := &http.Client{}
var responseJSON interface{}
request, _ := http.NewRequest("GET", "https://api.vulncheck.com/v3/index/initial-access", nil)
request.Header.Set("Accept", "application/json")
request.AddCookie(&http.Cookie{
Name: "token",
Value: "insert_token_here",
})
response, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
_ := json.NewDecoder(response.Body).Decode(responseJSON)
import requests
url = "https://api.vulncheck.com/v3/index/initial-access"
headers = {
"accept": "application/json"
}
cookies = {
"token": "insert_token_here"
}
response = requests.get(url, headers=headers, cookies=cookies)
print(response.json())
VulnCheck는 API와 상호 작용할 수 있는 CLI와 SDK를 제공합니다. VC_TOKEN 환경 변수를 설정하여 CLI 또는 SDK에서 토큰을 사용할 수 있습니다.
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"os"
vulncheck "github.com/vulncheck-oss/sdk-go-v2/v2"
)
func main() {
configuration := vulncheck.NewConfiguration()
configuration.Scheme = "https"
configuration.Host = "api.vulncheck.com"
client := vulncheck.NewAPIClient(configuration)
token := os.Getenv("VULNCHECK_API_TOKEN")
auth := context.WithValue(
context.Background(),
vulncheck.ContextAPIKeys,
map[string]vulncheck.APIKey{
"Bearer": {Key: token},
},
)
resp, httpRes, err := client.IndicesAPI.IndexInitialAccessGet(auth).Execute()
if err != nil || httpRes.StatusCode != 200 {
log.Fatal(err)
}
prettyJSON, err := json.MarshalIndent(resp.Data, "", " ")
if err != nil {
log.Fatalf("Failed to generate JSON: %v", err)
return
}
fmt.Println(string(prettyJSON))
}
import vulncheck_sdk
configuration = vulncheck_sdk.Configuration(host="https://api.vulncheck.com/v3")
configuration.api_key["Bearer"] = "insert_token_here"
with vulncheck_sdk.ApiClient(configuration) as api_client:
indices_client = vulncheck_sdk.IndicesApi(api_client)
api_response = indices_client.index_initial_access_get()
print(api_response.data)
export VC_TOKEN=insert_token_here
vulncheck index browse initial-access