Skip to content

Commit

Permalink
lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhadfield committed Apr 29, 2024
1 parent ab99122 commit fcc4c5f
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func initConfig(cmd *cobra.Command) error {
// initialise logging
initLogging(cmd)

conf.HttpClient = getHTTPClient()
conf.HTTPClient = getHTTPClient()

utd, err := cmd.Flags().GetBool("use-test-data")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ type Config struct {
MaxReports int `mapstructure:"max-reports"`
DisableCache bool `mapstructure:"disable-cache"`
} `mapstructure:"global"`
HttpClient *retryablehttp.Client
HTTPClient *retryablehttp.Client
Host netip.Addr
Providers Providers `mapstructure:"providers"`
HideProgress bool `mapstructure:"hide-progress"`
Expand Down
2 changes: 1 addition & 1 deletion providers/abuseipdb/abuseipdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func loadAPIResponse(ctx context.Context, c config.Config, apiKey string) (res *
req.Header.Add("Key", apiKey)
req.Header.Add("Accept", "application/json")

resp, err := c.HttpClient.Do(req)
resp, err := c.HTTPClient.Do(req)
if err != nil {
return nil, fmt.Errorf("failed to make request: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion providers/annotated/annotated.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ func getValidFilePathsFromDir(l *slog.Logger, dir string) (paths []os.DirEntry)
func LoadFilePrefixesWithAnnotationsFromPath(path string, prefixesWithAnnotations map[netip.Prefix][]annotation) error {
info, err := os.Stat(path)
if os.IsNotExist(err) {
return err
return err // nolint: wrapcheck
}

path, err = filepath.Abs(path)
Expand Down
6 changes: 3 additions & 3 deletions providers/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func unmarshalProviderData(rBody []byte) (*aws.Doc, error) {

func (c *ProviderClient) loadProviderData() error {
awsClient := aws.New()
awsClient.Client = c.HttpClient
awsClient.Client = c.HTTPClient

if c.Providers.AWS.URL != "" {
awsClient.DownloadURL = c.Providers.AWS.URL
Expand Down Expand Up @@ -128,7 +128,7 @@ func (c *ProviderClient) Initialise() error {
return nil
}

func loadTestData(c *ProviderClient) ([]byte, error) {
func loadTestData() ([]byte, error) {
tdf, err := loadResultsFile("providers/aws/testdata/aws_18_164_52_75_report.json")
if err != nil {
return nil, err
Expand Down Expand Up @@ -185,7 +185,7 @@ func (c *ProviderClient) FindHost() ([]byte, error) {
if c.UseTestData {
var loadErr error

out, loadErr = loadTestData(c)
out, loadErr = loadTestData()
if loadErr != nil {
return nil, loadErr
}
Expand Down
2 changes: 1 addition & 1 deletion providers/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const (

func (c *ProviderClient) loadProviderDataFromSource() error {
azureClient := azure.New()
azureClient.Client = c.HttpClient
azureClient.Client = c.HTTPClient

if c.Providers.Azure.URL != "" {
azureClient.DownloadURL = c.Providers.Azure.URL
Expand Down
4 changes: 2 additions & 2 deletions providers/criminalip/criminalip.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ func loadAPIResponse(ctx context.Context, conf *config.Config, apiKey string) (r
panic(err)
}

conf.HttpClient.HTTPClient.Timeout = 30 * time.Second
conf.HTTPClient.HTTPClient.Timeout = 30 * time.Second

req.Header.Add("x-api-key", apiKey)

resp, err := conf.HttpClient.Do(req)
resp, err := conf.HTTPClient.Do(req)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion providers/digitalocean/digitalocean.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func unmarshalProviderData(data []byte) (*digitalocean.Doc, error) {

func (c *ProviderClient) loadProviderData() error {
digitaloceanClient := digitalocean.New()
digitaloceanClient.Client = c.HttpClient
digitaloceanClient.Client = c.HTTPClient

if c.Providers.DigitalOcean.URL != "" {
digitaloceanClient.DownloadURL = c.Providers.DigitalOcean.URL
Expand Down
6 changes: 3 additions & 3 deletions providers/ipurl/ipurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ type StoredURLPrefixes struct {
}

func (c *ProviderClient) loadProviderURLsFromSource(providerUrls []string) error {
ic := ipfetcherURL.New(ipfetcherURL.WithHttpClient(c.HttpClient))
ic.HttpClient = c.HttpClient
ic := ipfetcherURL.New(ipfetcherURL.WithHttpClient(c.HTTPClient))
ic.HttpClient = c.HTTPClient

var wg sync.WaitGroup

Expand All @@ -244,7 +244,7 @@ func (c *ProviderClient) loadProviderURLsFromSource(providerUrls []string) error
// loadProviderDataFromSource fetches the data from the source and caches it for individual urls
func (c *ProviderClient) loadProviderURLFromSource(pURL string) ([]netip.Prefix, error) {
hf := ipfetcherURL.HttpFile{
Client: c.HttpClient,
Client: c.HTTPClient,
Url: pURL,
}

Expand Down
2 changes: 2 additions & 0 deletions providers/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ func PortMatchFilter(in PortMatchFilterInput) (ageMatch, netMatch bool, err erro
// TODO: Allow provider specific max value chars to override global
func PreProcessValueOutput(conf *config.Config, provider string, in string) string {
out := strings.TrimSpace(in)

// abbreviate output value if it exceeds max value chars
if conf.Global.MaxValueChars > 0 {
if len(out) > int(conf.Global.MaxValueChars) {
out = out[:conf.Global.MaxValueChars] + "..."
Expand Down
2 changes: 1 addition & 1 deletion providers/shodan/shodan.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func loadAPIResponse(ctx context.Context, c config.Config, apiKey string) (res *
return nil, fmt.Errorf("failed to create request: %w", err)
}

resp, err := c.HttpClient.Do(req)
resp, err := c.HTTPClient.Do(req)
if err != nil {
return nil, fmt.Errorf("failed to make request: %w", err)
}
Expand Down

0 comments on commit fcc4c5f

Please sign in to comment.