Skip to content
프로젝트

소개

Go client for the urlquery v2 API

보안 및 개인정보 보호

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
기록 수집 중
in 15 days
기록 수집 중
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

urlquery-api-go

Go Reference License: MIT

The Go client for the urlquery v2 API. urlquery analyzes URLs in an isolated browser and records what they do: redirects, HTTP traffic, scripts, downloads, detections and a screenshot.

With this package you can submit URLs and wait for the reports, read and compare reports, search a year of reports, look up reputation, explore Host Profile, and manage YARA rules, watchlists and page monitors, with typed results for every field.

Documentation: https://docs.urlquery.net/docs/libraries/go · API reference

This version is for the v2 API and replaces the earlier client for the deprecated v1 API. Its calls, names and types are new.

Install

go get github.com/urlquery/urlquery-api-go

It needs Go 1.25 or later, and an API key from your urlquery.net account.

Example

package main

import (
	"context"
	"fmt"
	"log"
	"os"
	"time"

	urlquery "github.com/urlquery/urlquery-api-go"
)

func main() {
	ctx := context.Background()
	c := urlquery.New(os.Getenv("URLQUERY_APIKEY"))

	// Analyze a URL as a restricted report and wait for it.
	access := urlquery.SubmissionRequestAccessRestricted
	s, err := c.Submit(ctx, urlquery.SubmissionRequest{URL: "https://example.com/login", Access: &access})
	if err != nil {
		log.Fatal(err)
	}
	if s, err = c.WaitForSubmission(ctx, s.QueueID, 5*time.Minute); err != nil {
		log.Fatal(err)
	}

	// The full report: every HTTP transaction, script and artifact.
	r, err := c.Report(ctx, s.ReportID)
	if err != nil {
		log.Fatal(err)
	}
	for _, t := range r.HTTP {
		fmt.Println(t.Response.StatusCode, t.URL.Addr)
	}

	// Every other report that loaded the same scripts.
	for _, script := range r.Javascript.Script {
		for hit, err := range c.AllSearchResults(ctx, "javascript.script.sha256:"+script.Sha256, urlquery.SearchOptions{}) {
			if err != nil {
				log.Fatal(err)
			}
			fmt.Println(script.Sha256[:12], hit.ReportID, hit.URL.Addr)
		}
	}
}

How it behaves

  • Typed results. The models are generated from the API's OpenAPI description, so every field of every response, down to the report's transactions, scripts and artifacts, has a Go type.
  • Paging. Each list method returns one page; its All… method is an iterator over every item, following cursors for you.
  • Rate limits and retries. A call waits out a rate limit for its Retry-After, and a GET is retried after a server error or a network failure; WithMaxRetryWait bounds the waiting. Submissions are never retried once they may have been queued.
  • Waiting for an analysis. WaitForSubmission polls until the analysis is done or has failed; when it gives up, it returns the last state it saw, so you keep the queue and report IDs.
  • Errors. API errors are *APIError values with the API's error code, such as NOT_FOUND or RATE_LIMIT_EXCEEDED.
  • Hostile content. Report content comes from the analyzed sites: treat titles, scripts and downloads as untrusted data.

Contributing

Report bugs and ask for features in the issues. Pull requests are welcome: this repository is published from urlquery's main repository, so an accepted change is applied there and arrives here with the next release. models.gen.go is generated from the API description; don't edit it by hand. For other questions, write to [email protected].

go test ./...

TestLive runs against the real API when URLQUERY_E2E_APIKEY is set. Use a key of a test account: it analyzes example.com and creates, then deletes, a YARA rule, a watchlist and a page monitor.

CHANGELOG.md lists the changes in each release. Report vulnerabilities privately, as SECURITY.md describes, not in an issue.

License

MIT © urlquery.net, see LICENSE.

관련 프로젝트 살펴보기

불러오는 중…