Skip to content

Find, verify, and analyze leaked credentials

Netlify Analyzer (#4106)

Kashif Khand20b3a4760fb
diff --git a/pkg/analyzer/analyzers/analyzers.go b/pkg/analyzer/analyzers/analyzers.go
index 972220435..9a5f542f6 100644
--- a/pkg/analyzer/analyzers/analyzers.go
+++ b/pkg/analyzer/analyzers/analyzers.go
@@ -94,6 +94,7 @@ const (
AnalyzerTypeLaunchDarkly
AnalyzerTypeFigma
AnalyzerTypePlaid
+ AnalyzerTypeNetlify
// Add new items here with AnalyzerType prefix
)
@@ -133,6 +134,7 @@ var analyzerTypeStrings = map[AnalyzerType]string{
AnalyzerTypeLaunchDarkly: "LaunchDarkly",
AnalyzerTypeFigma: "Figma",
AnalyzerTypePlaid: "Plaid",
+ AnalyzerTypeNetlify: "Netlify",
// Add new mappings here
}
diff --git a/pkg/analyzer/analyzers/netlify/models.go b/pkg/analyzer/analyzers/netlify/models.go
new file mode 100644
index 000000000..73a9f5c67
--- /dev/null
+++ b/pkg/analyzer/analyzers/netlify/models.go
@@ -0,0 +1,169 @@
+package netlify
+
+import "sync"
+
+type ResourceType string
+
+func (r ResourceType) String() string {
+ return string(r)
+}
+
+const (
+ CurrentUser ResourceType = "User"
+ Token ResourceType = "Token"
+ Site ResourceType = "Site"
+ SiteFile ResourceType = "Site File"
+ SiteEnvVar ResourceType = "Site Env Variable"
+ SiteSnippet ResourceType = "Site Snippet"
+ SiteDeploy ResourceType = "Site Deploy"
+ SiteDeployedBranch ResourceType = "Site Deployed Branch"
+ SiteBuild ResourceType = "Site Build"
+ SiteDevServer ResourceType = "Site Dev Server"
+ SiteBuildHook ResourceType = "Site Build Hook"
+ SiteDevServerHook ResourceType = "Site Dev Server Hook"
+ SiteServiceInstance ResourceType = "Site Service Instance"
+ SiteFunction ResourceType = "Site Function"
+ SiteForm ResourceType = "Site Form"
+ SiteSubmission ResourceType = "Site Submission"
+ SiteTrafficSplit ResourceType = "Site Traffic Split"
+ DNSZone ResourceType = "DNS Zone"
+ Service ResourceType = "Service"
+)
+
+type SecretInfo struct {
+ mu sync.RWMutex
+
+ UserInfo User
+ Resources []NetlifyResource
+}
+
+func (s *SecretInfo) appendResource(resource NetlifyResource) {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+
+ s.Resources = append(s.Resources, resource)
+}
+
+// listResourceByType returns a list of resources matching the given type.
+func (s *SecretInfo) listResourceByType(resourceType ResourceType) []NetlifyResource {
+ s.mu.RLock()
+ defer s.mu.RUnlock()
+
+ resources := make([]NetlifyResource, 0, len(s.Resources))
+ for _, resource := range s.Resources {
+ if resource.Type == resourceType.String() {
+ resources = append(resources, resource)
+ }
+ }
+
+ return resources
+}
+
+type User struct {
+ ID string `json:"id"`
+ Name string `json:"full_name"`
+ Email string `json:"email"`
+ AccountID string `json:"account_id"`
+ LastLogin string `json:"last_login"`
+}
+
+type NetlifyResource struct {
+ ID string
+ Name string
+ Type string
+ Metadata map[string]string
+ Parent *NetlifyResource
+}
+
+type token struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+ Personal bool `json:"personal"`
+ ExpiresAt string `json:"expires_at"`
+}
+
+type site struct {
+ SiteID string `json:"site_id"`
+ Name string `json:"name"`
+ Url string `json:"url"`
+ AdminUrl string `json:"admin_url"`
+ RepoUrl string `json:"repo_url"`
+}
+
+type file struct {
+ ID string `json:"id"`
+ Path string `json:"path"`
+ MimeType string `json:"mime_type"`
+}
+
+type envVariable struct {
+ Key string `json:"key"`
+ Scopes []string `json:"scopes"`
+ Values []struct {
+ ID string `json:"id"`
+ Value string `json:"value"`
+ } `json:"values"`
+}
+
+type snippet struct {
+ ID string `json:"id"`
+ Title string `json:"title"`
+}
+
+type deploy struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+ BuildID string `json:"build_id"`
+ State string `json:"state"`
+ Url string `json:"url"`
+}
+
+type deployedBranch struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+ Slug string `json:"slug"`
+}
+
+type build struct {
+ ID string `json:"id"`
+ DeployState string `json:"deploy_state"`
+}
+
+type devServer struct {
+ ID string `json:"id"`
+ Title string `json:"title"`
+}
+
+type buildHook struct {
+ ID string `json:"id"`
+ Title string `json:"title"`
+ Branch string `json:"branch"`
+}
+
+type serviceInstance struct {
+ ID string `json:"id"`
+ ServiceName string `json:"service_name"`
+ Url string `json:"url"`
+}
+
+type function struct {
+ ID string `json:"id"`
+ Provider string `json:"provider"`
+}
+
+// this handle response of 3 API's
+type formSubmissionSplitInfo struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+}
+
+type dnsZone struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+}
+
+type service struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+ ServicePath string `json:"service_path"`
+}
diff --git a/pkg/analyzer/analyzers/netlify/netlify.go b/pkg/analyzer/analyzers/netlify/netlify.go
new file mode 100644
index 000000000..89d25b03a
--- /dev/null
+++ b/pkg/analyzer/analyzers/netlify/netlify.go
@@ -0,0 +1,161 @@
+//go:generate generate_permissions permissions.yaml permissions.go netlify
+package netlify
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/fatih/color"
+ "github.com/jedib0t/go-pretty/v6/table"
+ "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers"
+ "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config"
+ "github.com/trufflesecurity/trufflehog/v3/pkg/context"
+)
+
+var _ analyzers.Analyzer = (*Analyzer)(nil)
+
+type Analyzer struct {
+ Cfg *config.Config
+}
+
+func (a Analyzer) Type() analyzers.AnalyzerType {
+ return analyzers.AnalyzerTypeNetlify
+}
+
+func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error) {
+ key, exist := credInfo["key"]
+ if !exist {
+ return nil, fmt.Errorf("key not found in credential info")
+ }
+
+ info, err := AnalyzePermissions(a.Cfg, key)
+ if err != nil {
+ return nil, err
+ }
+
+ return secretInfoToAnalyzerResult(info), nil
+}
+
+func AnalyzeAndPrintPermissions(cfg *config.Config, key string) {
+ info, err := AnalyzePermissions(cfg, key)
+ if err != nil {
+ // just print the error in cli and continue as a partial success
+ color.Red("[x] Error : %s", err.Error())
+ }
+
+ if info == nil {
+ color.Red("[x] Error : %s", "No information found")
+ return
+ }
+
+ color.Green("[!] Valid Fastly API key\n\n")
+
+ printUserInfo(info.UserInfo)
+ printTokenInfo(info.listResourceByType(Token))
+ printResources(info.Resources)
+
+ color.Yellow("\n[i] Expires: %s", "N/A (Refer to Token Information Table)")
+}
+
+func AnalyzePermissions(cfg *config.Config, key string) (*SecretInfo, error) {
+ client := analyzers.NewAnalyzeClient(cfg)
+
+ var secretInfo = &SecretInfo{}
+
+ if err := captureUserInfo(client, key, secretInfo); err != nil {
+ return nil, err
+ }
+
+ if err := captureTokens(client, key, secretInfo); err != nil {
+ return nil, err
+ }
+
+ if err := captureResources(client, key, secretInfo); err != nil {
+ return secretInfo, err
+ }
+
+ return secretInfo, nil
+}
+
+// secretInfoToAnalyzerResult translate secret info to Analyzer Result
+func secretInfoToAnalyzerResult(info *SecretInfo) *analyzers.AnalyzerResult {
+ if info == nil {
+ return nil
+ }
+
+ result := analyzers.AnalyzerResult{
+ AnalyzerType: analyzers.AnalyzerTypeNetlify,
+ Metadata: map[string]any{},
+ Bindings: make([]analyzers.Binding, 0),
+ }
+
+ // extract information from resource to create bindings and append to result bindings
+ for _, resource := range info.Resources {
+ binding := analyzers.Binding{
+ Resource: analyzers.Resource{
+ Name: resource.Name,
+ FullyQualifiedName: fmt.Sprintf("netlify/%s/%s", resource.Type, resource.ID), // e.g: netlify/site/123
+ Type: resource.Type,
+ Metadata: map[string]any{}, // to avoid panic
+ },
+ Permission: analyzers.Permission{
+ Value: PermissionStrings[FullAccess], // no fine grain access
+ },
+ }
+
+ if resource.Parent != nil {
+ binding.Resource.Parent = &analyzers.Resource{
+ Name: resource.Parent.Name,
+ FullyQualifiedName: resource.Parent.ID,
+ Type: resource.Parent.Type,
+ // not copying parent metadata
+ }
+ }
+
+ for key, value := range resource.Metadata {
+ binding.Resource.Metadata[key] = value
+ }
+
+ result.Bindings = append(result.Bindings, binding)
+ }
+
+ return &result
+}
+
+// cli print functions
+func printUserInfo(user User) {
+ color.Yellow("[i] User Information:")
+ t := table.NewWriter()
+ t.SetOutputMirror(os.Stdout)
+ t.AppendHeader(table.Row{"Name", "Email", "Account ID", "Last Login At"})
+ t.AppendRow(table.Row{color.GreenString(user.Name), color.GreenString(user.Email), color.GreenString(user.AccountID), color.GreenString(user.LastLogin)})
+
+ t.Render()
+}
+
+func printTokenInfo(tokens []NetlifyResource) {
+ color.Yellow("[i] Tokens Information:")
+ t := table.NewWriter()
+ t.SetOutputMirror(os.Stdout)
+ t.AppendHeader(table.Row{"ID", "Name", "Personal", "Expires At"})
+ for _, token := range tokens {
+ t.AppendRow(table.Row{color.GreenString(token.ID), color.GreenString(token.Name), color.GreenString(token.Metadata[tokenPersonal]), color.GreenString(token.Metadata[tokenExpiresAt])})
+ }
+ t.Render()
+}
+
+func printResources(resources []NetlifyResource) {
+ color.Yellow("[i] Resources:")
+ t := table.NewWriter()
+ t.SetOutputMirror(os.Stdout)
+ t.AppendHeader(table.Row{"Name", "Type"})
+ for _, resource := range resources {
+ // skip token type resource as we will print them separately
+ if resource.Type == Token.String() {
+ continue
+ }
+
+ t.AppendRow(table.Row{color.GreenString(resource.Name), color.GreenString(resource.Type)})
+ }
+ t.Render()
+}
diff --git a/pkg/analyzer/analyzers/netlify/netlify_test.go b/pkg/analyzer/analyzers/netlify/netlify_test.go
new file mode 100644
index 000000000..e3a024283
--- /dev/null
+++ b/pkg/analyzer/analyzers/netlify/netlify_test.go
@@ -0,0 +1,105 @@
+package netlify
+
+import (
+ _ "embed"
+ "encoding/json"
+ "fmt"
+ "sort"
+ "testing"
+ "time"
+
+ "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers"
+ "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config"
+ "github.com/trufflesecurity/trufflehog/v3/pkg/common"
+ "github.com/trufflesecurity/trufflehog/v3/pkg/context"
+)
+
+//go:embed result_output.json
+var expectedOutput []byte
+
+func TestAnalyzer_Analyze(t *testing.T) {
+ ctx, cancel := context.WithTimeout(context.Background(), time.Minute*5)
+ defer cancel()
+ testSecrets, err := common.GetSecret(ctx, "trufflehog-testing", "analyzers1")
+ if err != nil {
+ t.Fatalf("could not get test secrets from GCP: %s", err)
+ }
+
+ key := testSecrets.MustGetField("NETLIFY_PAT")
+
+ tests := []struct {
+ name string
+ key string
+ want []byte // JSON string
+ wantErr bool
+ }{
+ {
+ name: "valid netlify personal access token",
+ key: key,
+ want: expectedOutput,
+ wantErr: false,
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ a := Analyzer{Cfg: &config.Config{}}
+ got, err := a.Analyze(ctx, map[string]string{"key": tt.key})
+ if (err != nil) != tt.wantErr {
+ t.Errorf("Analyzer.Analyze() error = %v, wantErr %v", err, tt.wantErr)
+ return
+ }
+
+ // Bindings need to be in the same order to be comparable
+ sortBindings(got.Bindings)
+
+ // Marshal the actual result to JSON
+ gotJSON, err := json.Marshal(got)
+ if err != nil {
+ t.Fatalf("could not marshal got to JSON: %s", err)
+ }
+
+ fmt.Println(string(gotJSON))
+
+ // Parse the expected JSON string
+ var wantObj analyzers.AnalyzerResult
+ if err := json.Unmarshal([]byte(tt.want), &wantObj); err != nil {
+ t.Fatalf("could not unmarshal want JSON string: %s", err)
+ }
+
+ // Bindings need to be in the same order to be comparable
+ sortBindings(wantObj.Bindings)
+
+ // Marshal the expected result to JSON (to normalize)
+ wantJSON, err := json.Marshal(wantObj)
+ if err != nil {
+ t.Fatalf("could not marshal want to JSON: %s", err)
+ }
+
+ // Compare the JSON strings
+ if string(gotJSON) != string(wantJSON) {
+ // Pretty-print both JSON strings for easier comparison
+ var gotIndented, wantIndented []byte
+ gotIndented, err = json.MarshalIndent(got, "", " ")
+ if err != nil {
+ t.Fatalf("could not marshal got to indented JSON: %s", err)
+ }
+ wantIndented, err = json.MarshalIndent(wantObj, "", " ")
+ if err != nil {
+ t.Fatalf("could not marshal want to indented JSON: %s", err)
+ }
+ t.Errorf("Analyzer.Analyze() = %s, want %s", gotIndented, wantIndented)
+ }
+ })
+ }
+}
+
+// Helper function to sort bindings
+func sortBindings(bindings []analyzers.Binding) {
+ sort.SliceStable(bindings, func(i, j int) bool {
+ if bindings[i].Resource.Name == bindings[j].Resource.Name {
+ return bindings[i].Permission.Value < bindings[j].Permission.Value
+ }
+ return bindings[i].Resource.Name < bindings[j].Resource.Name
+ })
+}
diff --git a/pkg/analyzer/analyzers/netlify/permissions.go b/pkg/analyzer/analyzers/netlify/permissions.go
new file mode 100644
index 000000000..3f8205d0a
--- /dev/null
+++ b/pkg/analyzer/analyzers/netlify/permissions.go
@@ -0,0 +1,61 @@
+// Code generated by go generate; DO NOT EDIT.
+package netlify
+
+import "errors"
+
+type Permission int
+
+const (
+ Invalid Permission = iota
+ FullAccess Permission = iota
+)
+
+var (
+ PermissionStrings = map[Permission]string{
+ FullAccess: "full_access",
+ }
+
+ StringToPermission = map[string]Permission{
+ "full_access": FullAccess,
+ }
+
+ PermissionIDs = map[Permission]int{
+ FullAccess: 1,
+ }
+
+ IdToPermission = map[int]Permission{
+ 1: FullAccess,
+ }
+)
+
+// ToString converts a Permission enum to its string representation
+func (p Permission) ToString() (string, error) {
+ if str, ok := PermissionStrings[p]; ok {
+ return str, nil
+ }
+ return "", errors.New("invalid permission")
+}
+
+// ToID converts a Permission enum to its ID
+func (p Permission) ToID() (int, error) {
+ if id, ok := PermissionIDs[p]; ok {
+ return id, nil
+ }
+ return 0, errors.New("invalid permission")
+}
+
+// PermissionFromString converts a string representation to its Permission enum
+func PermissionFromString(s string) (Permission, error) {
+ if p, ok := StringToPermission[s]; ok {
+ return p, nil
+ }
+ return 0, errors.New("invalid permission string")
+}
+
+// PermissionFromID converts an ID to its Permission enum
+func PermissionFromID(id int) (Permission, error) {
+ if p, ok := IdToPermission[id]; ok {
+ return p, nil
+ }
+ return 0, errors.New("invalid permission ID")
+}
diff --git a/pkg/analyzer/analyzers/netlify/permissions.yaml b/pkg/analyzer/analyzers/netlify/permissions.yaml
new file mode 100644
index 000000000..fb4bbdffb
--- /dev/null
+++ b/pkg/analyzer/analyzers/netlify/permissions.yaml
@@ -0,0 +1,2 @@
+permissions:
+ - full_access
\ No newline at end of file
diff --git a/pkg/analyzer/analyzers/netlify/requests.go b/pkg/analyzer/analyzers/netlify/requests.go
new file mode 100644
index 000000000..e08035e29
--- /dev/null
+++ b/pkg/analyzer/analyzers/netlify/requests.go
@@ -0,0 +1,710 @@
+package netlify
+
+import (
+ "encoding/json"
+ "errors"
+ "fmt"
+ "io"
+ "net/http"
+ "strconv"
+ "strings"
+ "sync"
+)
+
+var (
+ apiEndpoints = map[ResourceType]string{
+ CurrentUser: "https://api.netlify.com/api/v1/user",
+ Token: "https://app.netlify.com/access-control/bb-api/api/v1/oauth/applications", // undocumented API - return personal tokens with metadata
+ Site: "https://api.netlify.com/api/v1/sites",
+ SiteFile: "https://api.netlify.com/api/v1/sites/%s/files", // require site id
+ SiteEnvVar: "https://api.netlify.com/api/v1/sites/%s/env", // require site id
+ SiteSnippet: "https://api.netlify.com/api/v1/sites/%s/snippets", // require site id
+ SiteDeploy: "https://api.netlify.com/api/v1/sites/%s/deploys", // require site id
+ SiteDeployedBranch: "https://api.netlify.com/api/v1/sites/%s/deployed-branches", // require site id
+ SiteBuild: "https://api.netlify.com/api/v1/sites/%s/builds", // require site id
+ SiteDevServer: "https://api.netlify.com/api/v1/sites/%s/dev_servers", // require site id
+ SiteBuildHook: "https://api.netlify.com/api/v1/sites/%s/build_hooks", // require site id
+ SiteDevServerHook: "https://api.netlify.com/api/v1/sites/%s/dev_server_hooks", // require site id
+ SiteServiceInstance: "https://api.netlify.com/api/v1/sites/%s/service-instances", // require site id
+ SiteFunction: "https://api.netlify.com/api/v1/sites/%s/functions", // require site id
+ SiteForm: "https://api.netlify.com/api/v1/sites/%s/forms", // require site id
+ SiteSubmission: "https://api.netlify.com/api/v1/sites/%s/submissions", // require site id
+ SiteTrafficSplit: "https://api.netlify.com/api/v1/sites/%s/traffic_splits", // require site id
+ DNSZone: "https://api.netlify.com/api/v1/dns_zones",
+ Service: "https://api.netlify.com/api/v1/services",
+
+ /*
+ TODO APIs:
+ - https://api.netlify.com/api/v1/sites/{site_id}/metadata (Just return key and values added as metadata for a site)
+ - https://api.netlify.com/api/v1/sites/{site_id}/assets/{asset_id} (Require asset id - No API to list assets)
+ - https://api.netlify.com/api/v1/deploy_keys (Have id and a public key in response only)
+ */
+ }
+
+ // metadata keys - should always start with resource name
+ tokenPersonal = "personal"
+ tokenExpiresAt = "expires_at"
+ siteUrl = "site_url"
+ siteAdminUrl = "site_admin_url"
+ siteRepoUrl = "site_repo_url"
+ fileMimeType = "site_mime_type"
+ deployBuildID = "deploy_build_id"
+ deployState = "deploy_state"
+ deployUrl = "deploy_url"
+ deployedBranchSlug = "deployed_branch_slug"
+ buildHookBranch = "build_hook_branch"
+ serviceInstanceUrl = "service_instance_url"
+)
+
+// makeNetlifyRequest send the API request to passed url with passed key as personal access token and return response body and status code
+func makeNetlifyRequest(client *http.Client, endpoint, key string) ([]byte, int, error) {
+ // create request
+ req, err := http.NewRequest(http.MethodGet, endpoint, http.NoBody)
+ if err != nil {
+ return nil, 0, err
+ }
+
+ // add key in the header
+ req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", key))
+
+ resp, err := client.Do(req)
+ if err != nil {
+ return nil, 0, err
+ }
+
+ defer func() {
+ _, _ = io.Copy(io.Discard, resp.Body)
+ _ = resp.Body.Close()
+ }()
+
+ responseBodyByte, err := io.ReadAll(resp.Body)
+ if err != nil {
+ return nil, 0, err
+ }
+
+ return responseBodyByte, resp.StatusCode, nil
+}
+
+// captureResources try to capture all the resource that the key can access
+func captureResources(client *http.Client, key string, secretInfo *SecretInfo) error {
+ var (
+ wg sync.WaitGroup
+ errAggWg sync.WaitGroup
+ aggregatedErrs = make([]error, 0)
+ errChan = make(chan error, 1)
+ )
+
+ errAggWg.Add(1)
+ go func() {
+ defer errAggWg.Done()
+ for err := range errChan {
+ aggregatedErrs = append(aggregatedErrs, err)
+ }
+ }()
+
+ // helper to launch tasks concurrently.
+ launchTask := func(task func() error) {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ if err := task(); err != nil {
+ errChan <- err
+ }
+ }()
+ }
+
+ // capture top level resources
+ if err := captureSites(client, key, secretInfo); err != nil {
+ return err
+ }
+
+ // capture all sub resources of all sites
+ sites := secretInfo.listResourceByType(Site)
+ for _, site := range sites {
+ launchTask(func() error { return captureSiteFiles(client, key, site, secretInfo) })
+ launchTask(func() error { return captureSiteEnvVar(client, key, site, secretInfo) })
+ launchTask(func() error { return captureSiteSnippets(client, key, site, secretInfo) })
+ launchTask(func() error { return captureSiteDeploys(client, key, site, secretInfo) })
+ launchTask(func() error { return captureSiteDeployedBranches(client, key, site, secretInfo) })
+ launchTask(func() error { return captureSiteBuilds(client, key, site, secretInfo) })
+ launchTask(func() error { return captureSiteDevServers(client, key, site, secretInfo) })
+ launchTask(func() error { return captureSiteBuildHooks(client, key, site, secretInfo) })
+ launchTask(func() error { return captureSiteDevServerHooks(client, key, site, secretInfo) })
+ launchTask(func() error { return captureSiteServiceInstances(client, key, site, secretInfo) })
+ launchTask(func() error { return captureSiteFunctions(client, key, site, secretInfo) })
+ launchTask(func() error { return captureSiteFormSubmissionSplitInfo(client, key, site, SiteForm, secretInfo) })
+ launchTask(func() error { return captureSiteFormSubmissionSplitInfo(client, key, site, SiteSubmission, secretInfo) })
+ launchTask(func() error {
+ return captureSiteFormSubmissionSplitInfo(client, key, site, SiteTrafficSplit, secretInfo)
+ })
+ }
+
+ launchTask(func() error { return captureDNSZones(client, key, secretInfo) })
+ launchTask(func() error { return captureServices(client, key, secretInfo) })
+
+ wg.Wait()
+ close(errChan)
+ errAggWg.Wait()
+
+ if len(aggregatedErrs) > 0 {
+ return errors.Join(aggregatedErrs...)
+ }
+
+ return nil
+}
+
+func captureUserInfo(client *http.Client, key string, secretInfo *SecretInfo) error {
+ respBody, statusCode, err := makeNetlifyRequest(client, apiEndpoints[CurrentUser], key)
+ if err != nil {
+ return err
+ }
+
+ switch statusCode {
+ case http.StatusOK:
+ var user User
+
+ if err := json.Unmarshal(respBody, &user); err != nil {
+ return err
+ }
+
+ secretInfo.UserInfo = user
+
+ return nil
+ case http.StatusUnauthorized:
+ return fmt.Errorf("invalid/expired personal access token")
+ default:
+ return fmt.Errorf("unexpected status code: %d for API: %s", statusCode, apiEndpoints[CurrentUser])
+ }
+}
+
+func captureTokens(client *http.Client, key string, secretInfo *SecretInfo) error {
+ respBody, statusCode, err := makeNetlifyRequest(client, apiEndpoints[Token], key)
+ if err != nil {
+ return err
+ }
+
+ switch statusCode {
+ case http.StatusOK:
+ var tokens []token
+
+ if err := json.Unmarshal(respBody, &tokens); err != nil {
+ return err
+ }
+
+ for _, token := range tokens {
+ if token.ExpiresAt == "" {
+ token.ExpiresAt = "never"
+ }
+
+ resource := NetlifyResource{
+ ID: token.ID,
+ Name: token.Name,
+ Type: Token.String(),
+ Metadata: map[string]string{
+ tokenExpiresAt: token.ExpiresAt,
+ tokenPersonal: strconv.FormatBool(token.Personal),
+ },
+ }
+
+ secretInfo.Resources = append(secretInfo.Resources, resource)
+ }
+
+ return nil
+ case http.StatusUnauthorized:
+ return fmt.Errorf("invalid/expired personal access token")
+ default:
+ return fmt.Errorf("unexpected status code: %d for API: %s", statusCode, apiEndpoints[Token])
+ }
+}
+
+func captureSites(client *http.Client, key string, secretInfo *SecretInfo) error {
+ respBody, statusCode, err := makeNetlifyRequest(client, apiEndpoints[Site], key)
+ if err != nil {
+ return err
+ }
+
+ switch statusCode {
+ case http.StatusOK:
+ var sites []site
+
+ if err := json.Unmarshal(respBody, &sites); err != nil {
+ return err
+ }
+
+ for _, site := range sites {
+ secretInfo.appendResource(NetlifyResource{
+ ID: site.SiteID,
+ Name: site.Name,
+ Type: Site.String(),
+ Metadata: map[string]string{
+ siteUrl: site.Url,
+ siteAdminUrl: site.AdminUrl,
+ siteRepoUrl: site.RepoUrl,
+ },
+ })
+ }
+
+ return nil
+ case http.StatusUnauthorized:
+ return fmt.Errorf("invalid/expired personal access token")
+ default:
+ return fmt.Errorf("unexpected status code: %d", statusCode)
+ }
+}
+
+func captureSiteFiles(client *http.Client, key string, site NetlifyResource, secretInfo *SecretInfo) error {
+ respBody, statusCode, err := makeNetlifyRequest(client, fmt.Sprintf(apiEndpoints[SiteFile], site.ID), key)
+ if err != nil {
+ return err
+ }
+
+ switch statusCode {
+ case http.StatusOK:
+ var files []file
+
+ if err := json.Unmarshal(respBody, &files); err != nil {
+ return err
+ }
+
+ for _, file := range files {
+ secretInfo.appendResource(NetlifyResource{
+ ID: site.ID + "/" + file.ID, // combine site id with file id to make it unique
+ Name: file.Path,
+ Type: SiteFile.String(),
+ Metadata: map[string]string{
+ fileMimeType: file.MimeType,
+ },
+ Parent: &site,
+ })
+ }
+
+ return nil
+ case http.StatusUnauthorized:
+ return fmt.Errorf("invalid/expired personal access token")
+ default:
+ return fmt.Errorf("unexpected status code: %d", statusCode)
+ }
+}
+
+func captureSiteEnvVar(client *http.Client, key string, site NetlifyResource, secretInfo *SecretInfo) error {
+ respBody, statusCode, err := makeNetlifyRequest(client, fmt.Sprintf(apiEndpoints[SiteEnvVar], site.ID), key)
+ if err != nil {
+ return err
+ }
+
+ switch statusCode {
+ case http.StatusOK:
+ var envVariables []envVariable
+
+ if err := json.Unmarshal(respBody, &envVariables); err != nil {
+ return err
+ }
+
+ for _, envVar := range envVariables {
+ // multiple values exist for each env variable, so we append separate resource for each value
+ for _, value := range envVar.Values {
+ secretInfo.appendResource(NetlifyResource{
+ ID: envVar.Key + "/" + value.ID,
+ Name: envVar.Key + "/***" + value.Value[len(value.Value)-4:], // append last 4 characters of value with key to make it unique
+ Type: SiteEnvVar.String(),
+ Metadata: map[string]string{
+ "value": value.Value,
+ "scopes": strings.Join(envVar.Scopes, ";"),
+ },
+ Parent: &site,
+ })
+ }
+ }
+
+ return nil
+ case http.StatusUnauthorized:
+ return fmt.Errorf("invalid/expired personal access token")
+ default:
+ return fmt.Errorf("unexpected status code: %d", statusCode)
+ }
+}
+
+func captureSiteSnippets(client *http.Client, key string, site NetlifyResource, secretInfo *SecretInfo) error {
+ respBody, statusCode, err := makeNetlifyRequest(client, fmt.Sprintf(apiEndpoints[SiteSnippet], site.ID), key)
+ if err != nil {
+ return err
+ }
+
+ switch statusCode {
+ case http.StatusOK:
+ var snippets []snippet
+
+ if err := json.Unmarshal(respBody, &snippets); err != nil {
+ return err
+ }
+
+ for _, snippet := range snippets {
+ secretInfo.appendResource(NetlifyResource{
+ ID: snippet.ID,
+ Name: snippet.Title,
+ Type: SiteSnippet.String(),
+ Parent: &site,
+ })
+ }
+
+ return nil
+ case http.StatusUnauthorized:
+ return fmt.Errorf("invalid/expired personal access token")
+ default:
+ return fmt.Errorf("unexpected status code: %d", statusCode)
+ }
+}
+
+func captureSiteDeploys(client *http.Client, key string, site NetlifyResource, secretInfo *SecretInfo) error {
+ respBody, statusCode, err := makeNetlifyRequest(client, fmt.Sprintf(apiEndpoints[SiteDeploy], site.ID), key)
+ if err != nil {
+ return err
+ }
+
+ switch statusCode {
+ case http.StatusOK:
+ var deploys []deploy
+
+ if err := json.Unmarshal(respBody, &deploys); err != nil {
+ return err
+ }
+
+ for _, deploy := range deploys {
+ secretInfo.appendResource(NetlifyResource{
+ ID: site.ID + "/deploy/" + deploy.ID,
+ Name: deploy.Name,
+ Type: SiteDeploy.String(),
+ Metadata: map[string]string{
+ deployBuildID: deploy.BuildID,
+ deployState: deploy.State,
+ deployUrl: deploy.Url,
+ },
+ Parent: &site,
+ })
+ }
+
+ return nil
+ case http.StatusUnauthorized:
+ return fmt.Errorf("invalid/expired personal access token")
+ default:
+ return fmt.Errorf("unexpected status code: %d", statusCode)
+ }
+}
+
+func captureSiteDeployedBranches(client *http.Client, key string, site NetlifyResource, secretInfo *SecretInfo) error {
+ respBody, statusCode, err := makeNetlifyRequest(client, fmt.Sprintf(apiEndpoints[SiteDeployedBranch], site.ID), key)
+ if err != nil {
+ return err
+ }
+
+ switch statusCode {
+ case http.StatusOK:
+ var deployedBranches []deployedBranch
+
+ if err := json.Unmarshal(respBody, &deployedBranches); err != nil {
+ return err
+ }
+
+ for _, deployedBranch := range deployedBranches {
+ secretInfo.appendResource(NetlifyResource{
+ ID: deployedBranch.ID,
+ Name: deployedBranch.Name,
+ Type: SiteDeployedBranch.String(),
+ Metadata: map[string]string{
+ deployedBranchSlug: deployedBranch.Slug,
+ },
+ Parent: &site,
+ })
+ }
+
+ return nil
+ case http.StatusUnauthorized:
+ return fmt.Errorf("invalid/expired personal access token")
+ default:
+ return fmt.Errorf("unexpected status code: %d", statusCode)
+ }
+}
+
+func captureSiteBuilds(client *http.Client, key string, site NetlifyResource, secretInfo *SecretInfo) error {
+ respBody, statusCode, err := makeNetlifyRequest(client, fmt.Sprintf(apiEndpoints[SiteBuild], site.ID), key)
+ if err != nil {
+ return err
+ }
+
+ switch statusCode {
+ case http.StatusOK:
+ var builds []build
+
+ if err := json.Unmarshal(respBody, &builds); err != nil {
+ return err
+ }
+
+ for _, build := range builds {
+ secretInfo.appendResource(NetlifyResource{
+ ID: build.ID,
+ Name: build.ID + "/state/" + build.DeployState, // no specific name
+ Type: SiteBuild.String(),
+ Parent: &site,
+ })
+ }
+
+ return nil
+ case http.StatusUnauthorized:
+ return fmt.Errorf("invalid/expired personal access token")
+ default:
+ return fmt.Errorf("unexpected status code: %d", statusCode)
+ }
+}
+
+func captureSiteDevServers(client *http.Client, key string, site NetlifyResource, secretInfo *SecretInfo) error {
+ respBody, statusCode, err := makeNetlifyRequest(client, fmt.Sprintf(apiEndpoints[SiteDevServer], site.ID), key)
+ if err != nil {
+ return err
+ }
+
+ switch statusCode {
+ case http.StatusOK:
+ var devServers []devServer
+
+ if err := json.Unmarshal(respBody, &devServers); err != nil {
+ return err
+ }
+
+ for _, devServer := range devServers {
+ secretInfo.appendResource(NetlifyResource{
+ ID: devServer.ID,
+ Name: devServer.Title,
+ Type: SiteDevServer.String(),
+ Parent: &site,
+ })
+ }
+
+ return nil
+ case http.StatusUnauthorized:
+ return fmt.Errorf("invalid/expired personal access token")
+ default:
+ return fmt.Errorf("unexpected status code: %d", statusCode)
+ }
+}
+
+func captureSiteBuildHooks(client *http.Client, key string, site NetlifyResource, secretInfo *SecretInfo) error {
+ respBody, statusCode, err := makeNetlifyRequest(client, fmt.Sprintf(apiEndpoints[SiteBuildHook], site.ID), key)
+ if err != nil {
+ return err
+ }
+
+ switch statusCode {
+ case http.StatusOK:
+ var hooks []buildHook
+
+ if err := json.Unmarshal(respBody, &hooks); err != nil {
+ return err
+ }
+
+ for _, hook := range hooks {
+ secretInfo.appendResource(NetlifyResource{
+ ID: hook.ID,
+ Name: hook.Title,
+ Type: SiteBuildHook.String(),
+ Metadata: map[string]string{
+ buildHookBranch: hook.Branch,
+ },
+ Parent: &site,
+ })
+ }
+
+ return nil
+ case http.StatusUnauthorized:
+ return fmt.Errorf("invalid/expired personal access token")
+ default:
+ return fmt.Errorf("unexpected status code: %d", statusCode)
+ }
+}
+
+func captureSiteDevServerHooks(client *http.Client, key string, site NetlifyResource, secretInfo *SecretInfo) error {
+ respBody, statusCode, err := makeNetlifyRequest(client, fmt.Sprintf(apiEndpoints[SiteDevServerHook], site.ID), key)
+ if err != nil {
+ return err
+ }
+
+ switch statusCode {
+ case http.StatusOK:
+ var devServerHooks []buildHook
+
+ if err := json.Unmarshal(respBody, &devServerHooks); err != nil {
+ return err
+ }
+
+ for _, hook := range devServerHooks {
+ secretInfo.appendResource(NetlifyResource{
+ ID: hook.ID,
+ Name: hook.Title,
+ Type: SiteDevServerHook.String(),
+ Metadata: map[string]string{
+ buildHookBranch: hook.Branch,
+ },
+ Parent: &site,
+ })
+ }
+
+ return nil
+ case http.StatusUnauthorized:
+ return fmt.Errorf("invalid/expired personal access token")
+ default:
+ return fmt.Errorf("unexpected status code: %d", statusCode)
+ }
+}
+
+func captureSiteServiceInstances(client *http.Client, key string, site NetlifyResource, secretInfo *SecretInfo) error {
+ respBody, statusCode, err := makeNetlifyRequest(client, fmt.Sprintf(apiEndpoints[SiteServiceInstance], site.ID), key)
+ if err != nil {
+ return err
+ }
+
+ switch statusCode {
+ case http.StatusOK:
+ var serviceInstances []serviceInstance
+
+ if err := json.Unmarshal(respBody, &serviceInstances); err != nil {
+ return err
+ }
+
+ for _, instance := range serviceInstances {
+ secretInfo.appendResource(NetlifyResource{
+ ID: instance.ID,
+ Name: instance.ServiceName + "/instance/" + instance.ID, // no specific name
+ Type: SiteServiceInstance.String(),
+ Metadata: map[string]string{
+ serviceInstanceUrl: instance.Url,
+ },
+ Parent: &site,
+ })
+ }
+
+ return nil
+ case http.StatusUnauthorized:
+ return fmt.Errorf("invalid/expired personal access token")
+ default:
+ return fmt.Errorf("unexpected status code: %d", statusCode)
+ }
+}
+
+func captureSiteFunctions(client *http.Client, key string, site NetlifyResource, secretInfo *SecretInfo) error {
+ respBody, statusCode, err := makeNetlifyRequest(client, fmt.Sprintf(apiEndpoints[SiteFunction], site.ID), key)
+ if err != nil {
+ return err
+ }
+
+ switch statusCode {
+ case http.StatusOK:
+ var data function
+
+ if err := json.Unmarshal(respBody, &data); err != nil {
+ return err
+ }
+
+ secretInfo.appendResource(NetlifyResource{
+ ID: data.ID,
+ Name: "function/" + data.ID + "/provider/" + data.Provider, // no specific name
+ Type: SiteFunction.String(),
+ Parent: &site,
+ })
+
+ return nil
+ case http.StatusUnauthorized:
+ return fmt.Errorf("invalid/expired personal access token")
+ default:
+ return fmt.Errorf("unexpected status code: %d", statusCode)
+ }
+}
+
+func captureSiteFormSubmissionSplitInfo(client *http.Client, key string, site NetlifyResource, resType ResourceType, secretInfo *SecretInfo) error {
+ respBody, statusCode, err := makeNetlifyRequest(client, fmt.Sprintf(apiEndpoints[resType], site.ID), key)
+ if err != nil {
+ return err
+ }
+
+ switch statusCode {
+ case http.StatusOK:
+ var formSubSplitInfos []formSubmissionSplitInfo
+
+ if err := json.Unmarshal(respBody, &formSubSplitInfos); err != nil {
+ return err
+ }
+
+ for _, info := range formSubSplitInfos {
+ secretInfo.appendResource(NetlifyResource{
+ ID: info.ID,
+ Name: info.Name, // no specific name
+ Type: resType.String(),
+ Parent: &site,
+ })
+ }
+
+ return nil
+ case http.StatusUnauthorized:
+ return fmt.Errorf("invalid/expired personal access token")
+ default:
+ return fmt.Errorf("unexpected status code: %d", statusCode)
+ }
+}
+
+func captureDNSZones(client *http.Client, key string, secretInfo *SecretInfo) error {
+ respBody, statusCode, err := makeNetlifyRequest(client, apiEndpoints[DNSZone], key)
+ if err != nil {
+ return err
+ }
+
+ switch statusCode {
+ case http.StatusOK:
+ var dnsZones []dnsZone
+
+ if err := json.Unmarshal(respBody, &dnsZones); err != nil {
+ return err
+ }
+
+ for _, dnsZone := range dnsZones {
+ secretInfo.appendResource(NetlifyResource{
+ ID: dnsZone.ID,
+ Name: dnsZone.Name,
+ Type: DNSZone.String(),
+ })
+ }
+
+ return nil
+ case http.StatusUnauthorized:
+ return fmt.Errorf("invalid/expired personal access token")
+ default:
+ return fmt.Errorf("unexpected status code: %d", statusCode)
+ }
+}
+
+func captureServices(client *http.Client, key string, secretInfo *SecretInfo) error {
+ respBody, statusCode, err := makeNetlifyRequest(client, apiEndpoints[Service], key)
+ if err != nil {
+ return err
+ }
+
+ switch statusCode {
+ case http.StatusOK:
+ var services []service
+
+ if err := json.Unmarshal(respBody, &services); err != nil {
+ return err
+ }
+
+ for _, service := range services {
+ secretInfo.appendResource(NetlifyResource{
+ ID: service.ID,
+ Name: service.Name,
+ Type: Service.String(),
+ })
+ }
+
+ return nil
+ case http.StatusUnauthorized:
+ return fmt.Errorf("invalid/expired personal access token")
+ default:
+ return fmt.Errorf("unexpected status code: %d", statusCode)
+ }
+}
diff --git a/pkg/analyzer/analyzers/netlify/result_output.json b/pkg/analyzer/analyzers/netlify/result_output.json
new file mode 100644
index 000000000..8c039061c
--- /dev/null
+++ b/pkg/analyzer/analyzers/netlify/result_output.json
@@ -0,0 +1,726 @@
+{
+ "AnalyzerType": 34,
+ "Bindings": [
+ {
+ "Resource": {
+ "Name": "/assets/404-bp-rpyh2.js",
+ "FullyQualifiedName": "netlify/Site File/dda81214-b126-43bf-9508-ae94cf9d0506//assets/404-bp-rpyh2.js",
+ "Type": "Site File",
+ "Metadata": {
+ "site_mime_type": "application/javascript"
+ },
+ "Parent": {
+ "Name": "truffle-test-site",
+ "FullyQualifiedName": "dda81214-b126-43bf-9508-ae94cf9d0506",
+ "Type": "Site",
+ "Metadata": null,
+ "Parent": null
+ }
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "/assets/about-c6ru7nfs.js",
+ "FullyQualifiedName": "netlify/Site File/dda81214-b126-43bf-9508-ae94cf9d0506//assets/about-c6ru7nfs.js",
+ "Type": "Site File",
+ "Metadata": {
+ "site_mime_type": "application/javascript"
+ },
+ "Parent": {
+ "Name": "truffle-test-site",
+ "FullyQualifiedName": "dda81214-b126-43bf-9508-ae94cf9d0506",
+ "Type": "Site",
+ "Metadata": null,
+ "Parent": null
+ }
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "/assets/index-bjt0jjds.css",
+ "FullyQualifiedName": "netlify/Site File/dda81214-b126-43bf-9508-ae94cf9d0506//assets/index-bjt0jjds.css",
+ "Type": "Site File",
+ "Metadata": {
+ "site_mime_type": "text/css"
+ },
+ "Parent": {
+ "Name": "truffle-test-site",
+ "FullyQualifiedName": "dda81214-b126-43bf-9508-ae94cf9d0506",
+ "Type": "Site",
+ "Metadata": null,
+ "Parent": null
+ }
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "/assets/index-csbqlcvs.js",
+ "FullyQualifiedName": "netlify/Site File/dda81214-b126-43bf-9508-ae94cf9d0506//assets/index-csbqlcvs.js",
+ "Type": "Site File",
+ "Metadata": {
+ "site_mime_type": "application/javascript"
+ },
+ "Parent": {
+ "Name": "truffle-test-site",
+ "FullyQualifiedName": "dda81214-b126-43bf-9508-ae94cf9d0506",
+ "Type": "Site",
+ "Metadata": null,
+ "Parent": null
+ }
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "/index.html",
+ "FullyQualifiedName": "netlify/Site File/dda81214-b126-43bf-9508-ae94cf9d0506//index.html",
+ "Type": "Site File",
+ "Metadata": {
+ "site_mime_type": "text/html"
+ },
+ "Parent": {
+ "Name": "truffle-test-site",
+ "FullyQualifiedName": "dda81214-b126-43bf-9508-ae94cf9d0506",
+ "Type": "Site",
+ "Metadata": null,
+ "Parent": null
+ }
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "/netlify.toml",
+ "FullyQualifiedName": "netlify/Site File/dda81214-b126-43bf-9508-ae94cf9d0506//netlify.toml",
+ "Type": "Site File",
+ "Metadata": {
+ "site_mime_type": "application/octet-stream"
+ },
+ "Parent": {
+ "Name": "truffle-test-site",
+ "FullyQualifiedName": "dda81214-b126-43bf-9508-ae94cf9d0506",
+ "Type": "Site",
+ "Metadata": null,
+ "Parent": null
+ }
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "680a1332fb8af883c4da6666/state/ready",
+ "FullyQualifiedName": "netlify/Site Build/680a1332fb8af883c4da6666",
+ "Type": "Site Build",
+ "Metadata": {},
+ "Parent": {
+ "Name": "truffle-test-site",
+ "FullyQualifiedName": "dda81214-b126-43bf-9508-ae94cf9d0506",
+ "Type": "Site",
+ "Metadata": null,
+ "Parent": null
+ }
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "Addon example",
+ "FullyQualifiedName": "netlify/Service/5ec5b30682bb8a00bad573ee",
+ "Type": "Service",
+ "Metadata": {},
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "DataStax Astra",
+ "FullyQualifiedName": "netlify/Service/5fadc1941f0b1600909ffe94",
+ "Type": "Service",
+ "Metadata": {},
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "DatoCMS Local",
+ "FullyQualifiedName": "netlify/Service/5bc77c2bac7ff24e6152b43c",
+ "Type": "Service",
+ "Metadata": {},
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "DatoCMS Staging",
+ "FullyQualifiedName": "netlify/Service/5bc77adbac7ff24e6152b43b",
+ "Type": "Service",
+ "Metadata": {},
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "Demo add-on",
+ "FullyQualifiedName": "netlify/Service/5c1abf2cac7ff2374d58fce2",
+ "Type": "Service",
+ "Metadata": {},
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "EXAMPLE_KEY/***ALUE",
+ "FullyQualifiedName": "netlify/Site Env Variable/EXAMPLE_KEY/0016840d-61c5-4e4a-aab4-8f9d73125846",
+ "Type": "Site Env Variable",
+ "Metadata": {
+ "scopes": "builds;functions;post_processing;runtime",
+ "value": "EXAMPLE_VALUE"
+ },
+ "Parent": {
+ "Name": "truffle-test-site",
+ "FullyQualifiedName": "dda81214-b126-43bf-9508-ae94cf9d0506",
+ "Type": "Site",
+ "Metadata": null,
+ "Parent": null
+ }
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "EXAMPLE_KEY_2/***anch",
+ "FullyQualifiedName": "netlify/Site Env Variable/EXAMPLE_KEY_2/c5d9d7f5-52f9-48a8-a218-a80d294f347e",
+ "Type": "Site Env Variable",
+ "Metadata": {
+ "scopes": "builds;functions;runtime",
+ "value": "****************anch"
+ },
+ "Parent": {
+ "Name": "truffle-test-site",
+ "FullyQualifiedName": "dda81214-b126-43bf-9508-ae94cf9d0506",
+ "Type": "Site",
+ "Metadata": null,
+ "Parent": null
+ }
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "EXAMPLE_KEY_2/***ocal",
+ "FullyQualifiedName": "netlify/Site Env Variable/EXAMPLE_KEY_2/b9df8f4a-7a18-4cc1-bf80-e0affa32569b",
+ "Type": "Site Env Variable",
+ "Metadata": {
+ "scopes": "builds;functions;runtime",
+ "value": "local"
+ },
+ "Parent": {
+ "Name": "truffle-test-site",
+ "FullyQualifiedName": "dda81214-b126-43bf-9508-ae94cf9d0506",
+ "Type": "Site",
+ "Metadata": null,
+ "Parent": null
+ }
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "EXAMPLE_KEY_2/***od_1",
+ "FullyQualifiedName": "netlify/Site Env Variable/EXAMPLE_KEY_2/1973b53f-60ab-40ce-ac23-20f6f2241fb3",
+ "Type": "Site Env Variable",
+ "Metadata": {
+ "scopes": "builds;functions;runtime",
+ "value": "****************od_1"
+ },
+ "Parent": {
+ "Name": "truffle-test-site",
+ "FullyQualifiedName": "dda81214-b126-43bf-9508-ae94cf9d0506",
+ "Type": "Site",
+ "Metadata": null,
+ "Parent": null
+ }
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "EXAMPLE_KEY_2/***ploy",
+ "FullyQualifiedName": "netlify/Site Env Variable/EXAMPLE_KEY_2/dab3426a-fb1e-405c-b89c-5143650e510e",
+ "Type": "Site Env Variable",
+ "Metadata": {
+ "scopes": "builds;functions;runtime",
+ "value": "****************ploy"
+ },
+ "Parent": {
+ "Name": "truffle-test-site",
+ "FullyQualifiedName": "dda81214-b126-43bf-9508-ae94cf9d0506",
+ "Type": "Site",
+ "Metadata": null,
+ "Parent": null
+ }
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "EXAMPLE_KEY_2/***thon",
+ "FullyQualifiedName": "netlify/Site Env Variable/EXAMPLE_KEY_2/658308b6-0cef-4987-a2a7-3235997af270",
+ "Type": "Site Env Variable",
+ "Metadata": {
+ "scopes": "builds;functions;runtime",
+ "value": "****************thon"
+ },
+ "Parent": {
+ "Name": "truffle-test-site",
+ "FullyQualifiedName": "dda81214-b126-43bf-9508-ae94cf9d0506",
+ "Type": "Site",
+ "Metadata": null,
+ "Parent": null
+ }
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "EXAMPLE_KEY_2/***view",
+ "FullyQualifiedName": "netlify/Site Env Variable/EXAMPLE_KEY_2/a210fa75-1194-42a2-8ff9-788bdf70d2b3",
+ "Type": "Site Env Variable",
+ "Metadata": {
+ "scopes": "builds;functions;runtime",
+ "value": "****************view"
+ },
+ "Parent": {
+ "Name": "truffle-test-site",
+ "FullyQualifiedName": "dda81214-b126-43bf-9508-ae94cf9d0506",
+ "Type": "Site",
+ "Metadata": null,
+ "Parent": null
+ }
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "Expired Token",
+ "FullyQualifiedName": "netlify/Token/680b33106d9ae981575b4dec",
+ "Type": "Token",
+ "Metadata": {
+ "expires_at": "2025-04-26T00:00:01.262Z",
+ "personal": "true"
+ },
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "Express Example",
+ "FullyQualifiedName": "netlify/Service/5b96e429ac7ff24ff6916ae1",
+ "Type": "Service",
+ "Metadata": {},
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "Fauna DB staging",
+ "FullyQualifiedName": "netlify/Service/5bbbea43ac7ff23902cc2a64",
+ "Type": "Service",
+ "Metadata": {},
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "FaunaDB Cloud",
+ "FullyQualifiedName": "netlify/Service/5bcf902fac7ff255bfc36233",
+ "Type": "Service",
+ "Metadata": {},
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "Get off my lawn",
+ "FullyQualifiedName": "netlify/Service/5ce6f8be82bb8a00b9940dfd",
+ "Type": "Service",
+ "Metadata": {},
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "Hasura GraphQL Engine",
+ "FullyQualifiedName": "netlify/Service/5c196638ac7ff255c853647e",
+ "Type": "Service",
+ "Metadata": {},
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "Joy Staging",
+ "FullyQualifiedName": "netlify/Service/5d23c4e682bb8a00ba311f23",
+ "Type": "Service",
+ "Metadata": {},
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "Netlify CMS Media Manager",
+ "FullyQualifiedName": "netlify/Service/5b9addcdac7ff27e11b0d4e4",
+ "Type": "Service",
+ "Metadata": {},
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "Nimbella",
+ "FullyQualifiedName": "netlify/Service/5f6d15de1f0b1600903dde32",
+ "Type": "Service",
+ "Metadata": {},
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "Nimbella Staging",
+ "FullyQualifiedName": "netlify/Service/5d9e587082bb8a00bb94943f",
+ "Type": "Service",
+ "Metadata": {},
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "No Exp Token",
+ "FullyQualifiedName": "netlify/Token/680b32c6bccfc08cd7732add",
+ "Type": "Token",
+ "Metadata": {
+ "expires_at": "never",
+ "personal": "true"
+ },
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "Takeshape CMS",
+ "FullyQualifiedName": "netlify/Service/5c9934a882bb8a00bc657db7",
+ "Type": "Service",
+ "Metadata": {},
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "Takeshape CMS staging",
+ "FullyQualifiedName": "netlify/Service/5c798b4582bb8a00b7504197",
+ "Type": "Service",
+ "Metadata": {},
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "VGS Staging",
+ "FullyQualifiedName": "netlify/Service/5be1c5bfac7ff267e9ba987b",
+ "Type": "Service",
+ "Metadata": {},
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "Very Good Security",
+ "FullyQualifiedName": "netlify/Service/5c6f1bbf82bb8a00bcdea659",
+ "Type": "Service",
+ "Metadata": {},
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "View source banner addon",
+ "FullyQualifiedName": "netlify/Service/5b9aef73ac7ff23d0a3fecd4",
+ "Type": "Service",
+ "Metadata": {},
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "analyzer-test(do not delete)",
+ "FullyQualifiedName": "netlify/Token/6810b09ab80020167d7525fe",
+ "Type": "Token",
+ "Metadata": {
+ "expires_at": "never",
+ "personal": "true"
+ },
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "function//provider/",
+ "FullyQualifiedName": "netlify/Site Function/",
+ "Type": "Site Function",
+ "Metadata": {},
+ "Parent": {
+ "Name": "truffle-test-site",
+ "FullyQualifiedName": "dda81214-b126-43bf-9508-ae94cf9d0506",
+ "Type": "Site",
+ "Metadata": null,
+ "Parent": null
+ }
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "hook1",
+ "FullyQualifiedName": "netlify/Site Build Hook/680a168ae30f218cd01bd4e8",
+ "Type": "Site Build Hook",
+ "Metadata": {
+ "build_hook_branch": "main"
+ },
+ "Parent": {
+ "Name": "truffle-test-site",
+ "FullyQualifiedName": "dda81214-b126-43bf-9508-ae94cf9d0506",
+ "Type": "Site",
+ "Metadata": null,
+ "Parent": null
+ }
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "test-app",
+ "FullyQualifiedName": "netlify/Token/6809f1dbfb8af846a8da644f",
+ "Type": "Token",
+ "Metadata": {
+ "expires_at": "never",
+ "personal": "false"
+ },
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "test01",
+ "FullyQualifiedName": "netlify/Token/6809f1b5830a5c43672123f8",
+ "Type": "Token",
+ "Metadata": {
+ "expires_at": "2025-05-24T08:09:25.796Z",
+ "personal": "true"
+ },
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "truffle-test-site",
+ "FullyQualifiedName": "netlify/Site/dda81214-b126-43bf-9508-ae94cf9d0506",
+ "Type": "Site",
+ "Metadata": {
+ "site_admin_url": "https://app.netlify.com/sites/truffle-test-site",
+ "site_repo_url": "",
+ "site_url": "http://truffle-test-site.netlify.app"
+ },
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "truffle-test-site",
+ "FullyQualifiedName": "netlify/Site Deploy/dda81214-b126-43bf-9508-ae94cf9d0506/deploy/680a1332fb8af883c4da6668",
+ "Type": "Site Deploy",
+ "Metadata": {
+ "deploy_build_id": "680a1332fb8af883c4da6666",
+ "deploy_state": "ready",
+ "deploy_url": "http://truffle-test-site.netlify.app"
+ },
+ "Parent": {
+ "Name": "truffle-test-site",
+ "FullyQualifiedName": "dda81214-b126-43bf-9508-ae94cf9d0506",
+ "Type": "Site",
+ "Metadata": null,
+ "Parent": null
+ }
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ },
+ {
+ "Resource": {
+ "Name": "trufflesecurity.com",
+ "FullyQualifiedName": "netlify/DNS Zone/6809f163830a5c42ca212432",
+ "Type": "DNS Zone",
+ "Metadata": {},
+ "Parent": null
+ },
+ "Permission": {
+ "Value": "full_access",
+ "Parent": null
+ }
+ }
+ ],
+ "UnboundedResources": null,
+ "Metadata": {}
+}
\ No newline at end of file
diff --git a/pkg/analyzer/cli.go b/pkg/analyzer/cli.go
index 3be98829f..643b28fe7 100644
--- a/pkg/analyzer/cli.go
+++ b/pkg/analyzer/cli.go
@@ -23,6 +23,7 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers/mailchimp"
"github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers/mailgun"
"github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers/mysql"
+ "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers/netlify"
"github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers/notion"
"github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers/openai"
"github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers/opsgenie"
@@ -121,5 +122,7 @@ func Run(keyType string, secretInfo SecretInfo) {
figma.AnalyzeAndPrintPermissions(secretInfo.Cfg, secretInfo.Parts["key"])
case "plaid":
plaid.AnalyzeAndPrintPermissions(secretInfo.Cfg, secretInfo.Parts["secret"], secretInfo.Parts["id"], secretInfo.Parts["token"])
+ case "netlify":
+ netlify.AnalyzeAndPrintPermissions(secretInfo.Cfg, secretInfo.Parts["key"])
}
}