Documentation
¶
Index ¶
- Constants
- Variables
- func BearerAllowed(nullifyHost string, req *http.Request) bool
- func GetGitHubID(ctx context.Context, githubOwner string) (string, error)
- func HTTPTimeout() time.Duration
- func HandleError(resp *http.Response) error
- func Int(value int) *int
- func NewRefreshingHTTPClient(nullifyHost string, tokenProvider, refreshProvider TokenProvider) (*http.Client, error)
- func NewRefreshingHTTPClientWithContext(ctx context.Context, nullifyHost string, ...) (*http.Client, error)
- func NewRetryTransport(transport http.RoundTripper) http.RoundTripper
- func String(value string) *string
- func StripBearerOnRedirect(req *http.Request, via []*http.Request) error
- type APIError
- type ContextTokenProvider
- type DASTCreateExternalScanInput
- type DASTCreateExternalScanOutput
- type DASTStartCloudScanInput
- type DASTStartCloudScanOutput
- type DASTUpdateExternalScanInput
- type HTTPClient
- type NullifyClient
- func (c *NullifyClient) DASTCreateExternalScan(ctx context.Context, githubOwner string, input *DASTCreateExternalScanInput) (*DASTCreateExternalScanOutput, error)
- func (c *NullifyClient) DASTStartCloudScan(ctx context.Context, githubOwner string, input *DASTStartCloudScanInput) (*DASTStartCloudScanOutput, error)
- func (c *NullifyClient) DASTUpdateExternalScan(ctx context.Context, githubOwner string, githubRepository string, ...) error
- type TokenProvider
Constants ¶
const DefaultHTTPTimeout = 30 * time.Second
DefaultHTTPTimeout is the request timeout used when NULLIFY_HTTP_TIMEOUT is unset or invalid. 30s is too short for long-running calls (scan-start, autofix), so callers can raise it via the env var (e.g. "120s").
const (
StatusCompleted = "completed"
)
Variables ¶
var ErrTokenNotRefreshable = errors.New("token source cannot be refreshed")
ErrTokenNotRefreshable reports that the active token source yields a fixed string, so retrying after a 401 cannot produce a different token.
Functions ¶
func BearerAllowed ¶ added in v0.27.0
BearerAllowed reports whether req may carry the Nullify bearer for nullifyHost; see bearerAllowed.
func GetGitHubID ¶ added in v0.9.15
func HTTPTimeout ¶ added in v0.27.0
HTTPTimeout returns the request timeout, overridable via the NULLIFY_HTTP_TIMEOUT env var (a Go duration string such as "120s").
func HandleError ¶
HandleError reads an HTTP error response and returns a structured *APIError.
func NewRefreshingHTTPClient ¶ added in v0.20.0
func NewRefreshingHTTPClient(nullifyHost string, tokenProvider, refreshProvider TokenProvider) (*http.Client, error)
NewRefreshingHTTPClient returns an *http.Client whose transport injects a Nullify bearer token (refreshed on a TTL) and retries transient failures. It is suitable for driving the generated api.Client in long-running processes like the MCP server, where a token fetched at startup would otherwise expire. refreshProvider is used to recover from a 401 and must bypass any cached expiry; passing tokenProvider for both makes the 401 retry a no-op.
func NewRefreshingHTTPClientWithContext ¶ added in v0.27.0
func NewRefreshingHTTPClientWithContext(ctx context.Context, nullifyHost string, tokenProvider, refreshProvider ContextTokenProvider) (*http.Client, error)
NewRefreshingHTTPClientWithContext uses ctx for the initial token and each request's context for later token reads and refreshes.
func NewRetryTransport ¶ added in v0.13.0
func NewRetryTransport(transport http.RoundTripper) http.RoundTripper
NewRetryTransport wraps the given transport with retry logic for 429 and 5xx errors.
func StripBearerOnRedirect ¶ added in v0.27.0
StripBearerOnRedirect is an http.Client CheckRedirect that follows a redirect without the Nullify bearer: the Location is the server's to choose and the user's token must not go wherever it points.
Types ¶
type APIError ¶ added in v0.12.0
APIError is an alias for apierror.APIError for backwards compatibility.
type ContextTokenProvider ¶ added in v0.27.0
ContextTokenProvider returns a token within the caller's context.
type DASTCreateExternalScanInput ¶ added in v0.7.0
type DASTCreateExternalScanOutput ¶ added in v0.7.0
type DASTCreateExternalScanOutput struct {
ScanID string `json:"scanId"`
}
type DASTStartCloudScanInput ¶ added in v0.4.0
type DASTStartCloudScanInput struct {
AppName string `json:"appName"`
TargetHost string `json:"targetHost"`
OpenAPISpec map[string]any `json:"openAPISpec"`
AuthConfig models.AuthConfig `json:"authConfig"`
models.RequestProvider
models.RequestDashboardTarget
}
type DASTStartCloudScanOutput ¶ added in v0.7.0
type DASTStartCloudScanOutput struct {
ScanID string `json:"scanId"`
}
type DASTUpdateExternalScanInput ¶ added in v0.7.0
type DASTUpdateExternalScanInput struct {
Progress *int `json:"progress"`
Status *string `json:"status"`
Findings []models.DASTFinding `json:"findings"`
*models.RequestDashboardTarget
}
type HTTPClient ¶ added in v0.12.0
HTTPClient defines the interface for making HTTP requests.
type NullifyClient ¶ added in v0.4.0
type NullifyClient struct {
Host string
BaseURL string
Token string
HttpClient HTTPClient
}
NullifyClient wraps an HTTP client configured for the Nullify API.
func NewNullifyClient ¶ added in v0.4.0
func NewNullifyClient(nullifyHost string, token string) *NullifyClient
NewNullifyClient creates a client for the given host with bearer token auth.
func NewRefreshingNullifyClient ¶ added in v0.13.0
func NewRefreshingNullifyClient(nullifyHost string, tokenProvider, refreshProvider TokenProvider) (*NullifyClient, error)
NewRefreshingNullifyClient creates a NullifyClient that automatically refreshes its auth token, suitable for long-running processes like MCP servers.
func (*NullifyClient) DASTCreateExternalScan ¶ added in v0.7.0
func (c *NullifyClient) DASTCreateExternalScan( ctx context.Context, githubOwner string, input *DASTCreateExternalScanInput, ) (*DASTCreateExternalScanOutput, error)
func (*NullifyClient) DASTStartCloudScan ¶ added in v0.4.0
func (c *NullifyClient) DASTStartCloudScan( ctx context.Context, githubOwner string, input *DASTStartCloudScanInput, ) (*DASTStartCloudScanOutput, error)
func (*NullifyClient) DASTUpdateExternalScan ¶ added in v0.7.0
func (c *NullifyClient) DASTUpdateExternalScan( ctx context.Context, githubOwner string, githubRepository string, scanID string, input *DASTUpdateExternalScanInput, ) error
type TokenProvider ¶ added in v0.13.0
TokenProvider is a function that returns a valid token.