Projects STRLCPY bearer Commits f16c3a25
🤬
  • ■ ■ ■ ■ ■
    pkg/commands/scan.go
    skipped 4 lines
    5 5   
    6 6   "github.com/bearer/bearer/pkg/commands/artifact"
    7 7   "github.com/bearer/bearer/pkg/flag"
     8 + "github.com/bearer/bearer/pkg/util/file"
    8 9   "github.com/bearer/bearer/pkg/util/output"
     10 + "github.com/rs/zerolog/log"
    9 11   "github.com/spf13/cobra"
    10 12   "github.com/spf13/viper"
    11 13   "golang.org/x/xerrors"
    skipped 42 lines
    54 56   }
    55 57   
    56 58   configPath := viper.GetString(flag.ConfigFileFlag.ConfigName)
     59 + defaultConfigPath := file.GetFullFilename(args[0], configPath)
    57 60   
     61 + loadedFile := false
    58 62   if err := readConfig(configPath); err != nil {
    59  - return err
     63 + if err := readConfig(defaultConfigPath); err != nil {
     64 + log.Debug().Msgf("Couldn't find config file %s or %s", configPath, defaultConfigPath)
     65 + } else {
     66 + log.Debug().Msgf("Loading default config file %s", defaultConfigPath)
     67 + loadedFile = true
     68 + }
     69 + } else {
     70 + log.Debug().Msgf("Loading config file %s", configPath)
     71 + loadedFile = true
    60 72   }
    61 73   
    62 74   options, err := ScanFlags.ToOptions(args)
    skipped 1 lines
    64 76   return xerrors.Errorf("flag error: %w", err)
    65 77   }
    66 78   
    67  - if !options.Quiet && configPath != "" {
    68  - output.StdErrLogger().Msgf("Loaded %s configuration file", configPath)
     79 + if !options.Quiet && loadedFile {
     80 + output.StdErrLogger().Msgf("Loaded configuration file")
    69 81   }
    70 82   
    71 83   output.Setup(cmd, options)
    skipped 33 lines
  • ■ ■ ■ ■
    pkg/flag/general_flags.go
    skipped 24 lines
    25 25   ConfigFileFlag = Flag{
    26 26   Name: "config-file",
    27 27   ConfigName: "config-file",
    28  - Value: "",
     28 + Value: "bearer.yml",
    29 29   Usage: "Load configuration from the specified path.",
    30 30   DisableInConfig: true,
    31 31   }
    skipped 60 lines
  • ■ ■ ■ ■ ■
    pkg/report/output/dataflow/dataflow.go
    skipped 3 lines
    4 4   "bytes"
    5 5   "encoding/json"
    6 6   "fmt"
    7  - "strings"
    8 7   
    9 8   "github.com/bearer/bearer/pkg/commands/process/settings"
    10 9   "github.com/bearer/bearer/pkg/report/customdetectors"
    skipped 3 lines
    14 13   "github.com/bearer/bearer/pkg/report/output/dataflow/datatypes"
    15 14   "github.com/bearer/bearer/pkg/report/output/dataflow/detectiondecoder"
    16 15   "github.com/bearer/bearer/pkg/report/output/dataflow/risks"
     16 + "github.com/bearer/bearer/pkg/util/file"
    17 17   "github.com/bearer/bearer/pkg/util/output"
    18 18   "github.com/hhatto/gocloc"
    19 19   
    skipped 75 lines
    95 95   }
    96 96   
    97 97   // add full path to filename
    98  - fullFilename := GetFullFilename(config.Target, castDetection.Source.Filename)
     98 + fullFilename := file.GetFullFilename(config.Target, castDetection.Source.Filename)
    99 99   castDetection.Source.Filename = fullFilename
    100 100   
    101 101   switch detectionType {
    skipped 86 lines
    188 188   return dataflow, nil, nil, nil
    189 189  }
    190 190   
    191  -func GetFullFilename(path string, filename string) string {
    192  - path = strings.TrimSuffix(path, "/")
    193  - filename = strings.TrimPrefix(filename, "/")
    194  - 
    195  - if filename == "." {
    196  - return path
    197  - }
    198  - 
    199  - if path == "" || path == "." {
    200  - return filename
    201  - }
    202  - 
    203  - return path + "/" + filename
    204  -}
    205  - 
  • ■ ■ ■ ■ ■ ■
    pkg/report/output/output.go
    skipped 14 lines
    15 15   "github.com/bearer/bearer/pkg/commands/process/settings"
    16 16   "github.com/bearer/bearer/pkg/flag"
    17 17   "github.com/bearer/bearer/pkg/report/output/dataflow"
    18  - dataflowoutput "github.com/bearer/bearer/pkg/report/output/dataflow"
    19 18   "github.com/bearer/bearer/pkg/report/output/privacy"
    20 19   "github.com/bearer/bearer/pkg/report/output/security"
     20 + "github.com/bearer/bearer/pkg/util/file"
    21 21   "github.com/gitsight/go-vcsurl"
    22 22   "github.com/google/uuid"
    23 23   
    skipped 65 lines
    89 89   filesDiscovered, _ := filelist.Discover(config.Scan.Target, config)
    90 90   files := []string{}
    91 91   for _, fileDiscovered := range filesDiscovered {
    92  - files = append(files, dataflowoutput.GetFullFilename(config.Scan.Target, fileDiscovered.FilePath))
     92 + files = append(files, file.GetFullFilename(config.Scan.Target, fileDiscovered.FilePath))
    93 93   }
    94 94   
    95 95   return files
    skipped 232 lines
  • ■ ■ ■ ■ ■ ■
    pkg/util/file/file.go
    skipped 326 lines
    327 327   return "", nil
    328 328  }
    329 329   
     330 +func GetFullFilename(path string, filename string) string {
     331 + path = strings.TrimSuffix(path, "/")
     332 + filename = strings.TrimPrefix(filename, "/")
     333 + 
     334 + if filename == "." {
     335 + return path
     336 + }
     337 + 
     338 + if path == "" || path == "." {
     339 + return filename
     340 + }
     341 + 
     342 + return path + "/" + filename
     343 +}
     344 + 
Please wait...
Page is in error, reload to recover