Skip to content

Commit

Permalink
all: mv gosec directives
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Oct 31, 2024
1 parent 59324e6 commit f5ba230
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 5 additions & 3 deletions internal/cmd/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ type cacheConfig struct {
// c must be valid.
func (c *cacheConfig) toInternal() (conf *dnssvc.CacheConfig) {
return &dnssvc.CacheConfig{
Enabled: c.Enabled,
Size: c.Size,
ClientSize: c.ClientSize,
Enabled: c.Enabled,
// #nosec G115 -- The value is validated to not exceed [math.MaxInt].
Size: int(c.Size),
// #nosec G115 -- The value is validated to not exceed [math.MaxInt].
ClientSize: int(c.ClientSize),
}
}

Expand Down
10 changes: 6 additions & 4 deletions internal/dnssvc/cache.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package dnssvc

import "github.com/c2h5oh/datasize"

// CacheConfig is the configuration for the DNS results cache.
type CacheConfig struct {
// Enabled specifies if the cache should be used.
Enabled bool

// Size is the maximum size of the common cache.
Size datasize.ByteSize
//
// TODO(e.burkov): Make it a [datasize.ByteSize] when dnsproxy uses it.
Size int

// ClientSize is the maximum size of each per-client cache.
ClientSize datasize.ByteSize
//
// TODO(e.burkov): Make it a [datasize.ByteSize] when dnsproxy uses it.
ClientSize int
}

// TODO(e.burkov): Add tests.
4 changes: 1 addition & 3 deletions internal/dnssvc/clientstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ func (confs upstreamConfigs) clients(cacheConf *CacheConfig) (clients []*client)
conf: proxy.NewCustomUpstreamConfig(
conf,
cacheConf.Enabled,
// #nosec G115 -- The value is validated to be less or equal to
// [math.MaxInt].
int(cacheConf.ClientSize),
cacheConf.ClientSize,
false,
),
prefix: cli,
Expand Down
6 changes: 2 additions & 4 deletions internal/dnssvc/dnssvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,8 @@ func newProxyConfig(
UsePrivateRDNS: private != nil,
Fallbacks: falls,
TrustedProxies: trusted,
// #nosec G115 -- The value is validated to be less or equal to
// [math.MaxInt].
CacheSizeBytes: int(conf.Cache.Size),
CacheEnabled: conf.Cache.Enabled,
CacheSizeBytes: conf.Cache.Size,
CacheEnabled: conf.Cache.Enabled,
}, ups.clients(conf.Cache), nil
}

Expand Down

0 comments on commit f5ba230

Please sign in to comment.