mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 13:14:22 +01:00
fix: ignore baseline if path was not relative in source (#1101)
* fix: ignore baseline if path was not relative in source Signed-off-by: Raffael Sahli <raffael.sahli@doodle.com> * test: ignore test secret --------- Signed-off-by: Raffael Sahli <raffael.sahli@doodle.com>
This commit is contained in:
1 parent
088f8b8074
commit
025908808f
4 files changed
+35
-5
No files matched your search
+20
-1
@@ -160,14 +160,33 @@ func (d *Detector) AddGitleaksIgnore(gitleaksIgnorePath string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Detector) AddBaseline(baselinePath string) error {
|
||||
func (d *Detector) AddBaseline(baselinePath string, source string) error {
|
||||
if baselinePath != "" {
|
||||
absoluteSource, err := filepath.Abs(source)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
absoluteBaseline, err := filepath.Abs(baselinePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
relativeBaseline, err := filepath.Rel(absoluteSource, absoluteBaseline)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
baseline, err := LoadBaseline(baselinePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d.baseline = baseline
|
||||
baselinePath = relativeBaseline
|
||||
|
||||
}
|
||||
|
||||
d.baselinePath = baselinePath
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user