Skip to content

Commit 7acd50a

Browse files
dogancanbakirx-stp
authored andcommitted
read key from env if provided (projectdiscovery#1607)
* read key from env if provided * remove debug code
1 parent aa9b5ad commit 7acd50a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

v2/pkg/passive/sources.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package passive
22

33
import (
4+
"fmt"
5+
"os"
46
"strings"
57

68
"golang.org/x/exp/maps"
@@ -168,6 +170,15 @@ func New(sourceNames, excludedSourceNames []string, useAllSources, useSourcesSup
168170
}
169171
}
170172

173+
// TODO: Consider refactoring this to avoid potential duplication issues
174+
for _, source := range sources {
175+
if source.NeedsKey() {
176+
if apiKey := os.Getenv(fmt.Sprintf("%s_API_KEY", strings.ToUpper(source.Name()))); apiKey != "" {
177+
source.AddApiKeys([]string{apiKey})
178+
}
179+
}
180+
}
181+
171182
// Create the agent, insert the sources and remove the excluded sources
172183
agent := &Agent{sources: maps.Values(sources)}
173184

0 commit comments

Comments
 (0)