mirror of
https://github.com/bakito/adguardhome-sync.git
synced 2025-01-07 15:49:13 +08:00
apply gosec findings
This commit is contained in:
parent
8a6f73f9c2
commit
5fe0e24839
3 changed files with 13 additions and 7 deletions
|
@ -35,8 +35,8 @@ const (
|
|||
configReplicaInsecureSkipVerify = "replica.insecureSkipVerify"
|
||||
configReplicaAutoSetup = "replica.autoSetup"
|
||||
|
||||
envReplicasUsernameFormat = "REPLICA%s_USERNAME"
|
||||
envReplicasPasswordFormat = "REPLICA%s_PASSWORD"
|
||||
envReplicasUsernameFormat = "REPLICA%s_USERNAME" // #nosec G101
|
||||
envReplicasPasswordFormat = "REPLICA%s_PASSWORD" // #nosec G101
|
||||
envReplicasAPIPathFormat = "REPLICA%s_APIPATH"
|
||||
envReplicasInsecureSkipVerifyFormat = "REPLICA%s_INSECURESKIPVERIFY"
|
||||
envReplicasAutoSetup = "REPLICA%s_AUTOSETUP"
|
||||
|
|
|
@ -36,6 +36,7 @@ func New(config types.AdGuardInstance) (Client, error) {
|
|||
cl := resty.New().SetHostURL(u.String()).SetDisableWarn(true)
|
||||
|
||||
if config.InsecureSkipVerify {
|
||||
// #nosec G402 has to be explicitly enabled
|
||||
cl.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})
|
||||
}
|
||||
|
||||
|
@ -169,7 +170,8 @@ func (cl *client) RewriteList() (*types.RewriteEntries, error) {
|
|||
}
|
||||
|
||||
func (cl *client) AddRewriteEntries(entries ...types.RewriteEntry) error {
|
||||
for _, e := range entries {
|
||||
for i := range entries {
|
||||
e := entries[i]
|
||||
cl.log.With("domain", e.Domain, "answer", e.Answer).Info("Add rewrite entry")
|
||||
err := cl.doPost(cl.client.R().EnableTrace().SetBody(&e), "/rewrite/add")
|
||||
if err != nil {
|
||||
|
@ -180,7 +182,8 @@ func (cl *client) AddRewriteEntries(entries ...types.RewriteEntry) error {
|
|||
}
|
||||
|
||||
func (cl *client) DeleteRewriteEntries(entries ...types.RewriteEntry) error {
|
||||
for _, e := range entries {
|
||||
for i := range entries {
|
||||
e := entries[i]
|
||||
cl.log.With("domain", e.Domain, "answer", e.Answer).Info("Delete rewrite entry")
|
||||
err := cl.doPost(cl.client.R().EnableTrace().SetBody(&e), "/rewrite/delete")
|
||||
if err != nil {
|
||||
|
@ -314,7 +317,8 @@ func (cl *client) Clients() (*types.Clients, error) {
|
|||
}
|
||||
|
||||
func (cl *client) AddClients(clients ...types.Client) error {
|
||||
for _, client := range clients {
|
||||
for i := range clients {
|
||||
client := clients[i]
|
||||
cl.log.With("name", client.Name).Info("Add client")
|
||||
err := cl.doPost(cl.client.R().EnableTrace().SetBody(&client), "/clients/add")
|
||||
if err != nil {
|
||||
|
@ -336,7 +340,8 @@ func (cl *client) UpdateClients(clients ...types.Client) error {
|
|||
}
|
||||
|
||||
func (cl *client) DeleteClients(clients ...types.Client) error {
|
||||
for _, client := range clients {
|
||||
for i := range clients {
|
||||
client := clients[i]
|
||||
cl.log.With("name", client.Name).Info("Delete client")
|
||||
err := cl.doPost(cl.client.R().EnableTrace().SetBody(&client), "/clients/delete")
|
||||
if err != nil {
|
||||
|
|
|
@ -171,7 +171,8 @@ func (f Filters) Merge(other Filters) (Filters, Filters, Filters) {
|
|||
current[f.URL] = f
|
||||
}
|
||||
|
||||
for _, rr := range other {
|
||||
for i := range other {
|
||||
rr := other[i]
|
||||
if c, ok := current[rr.URL]; ok {
|
||||
if !c.Equals(&rr) {
|
||||
updates = append(updates, rr)
|
||||
|
|
Loading…
Reference in a new issue