@@ -47,7 +47,7 @@ func New(repoService provider.IProvider, slackService slack.IService, osvService
4747
4848// Patrol scans the given Gitlab groups and projects, creates and publishes the necessary reports.
4949func (s * sheriffService ) Patrol (args config.PatrolConfig ) (warn error , err error ) {
50- scanReports , swarn , err := s .scanAndGetReports (args .Locations )
50+ scanReports , swarn , err := s .scanAndGetReports (args .Locations , args . Ignored )
5151 if err != nil {
5252 return nil , errors .Join (errors .New ("failed to scan projects" ), err )
5353 }
@@ -96,7 +96,7 @@ func (s *sheriffService) Patrol(args config.PatrolConfig) (warn error, err error
9696 return warn , nil
9797}
9898
99- func (s * sheriffService ) scanAndGetReports (locations []config.ProjectLocation ) (reports []scanner.Report , warn error , err error ) {
99+ func (s * sheriffService ) scanAndGetReports (locations []config.ProjectLocation , ignored []config. ProjectLocation ) (reports []scanner.Report , warn error , err error ) {
100100 // Create a temporary directory to store the scans
101101 err = os .MkdirAll (tempScanDir , os .ModePerm )
102102 if err != nil {
@@ -105,7 +105,7 @@ func (s *sheriffService) scanAndGetReports(locations []config.ProjectLocation) (
105105 defer os .RemoveAll (tempScanDir )
106106 log .Info ().Str ("path" , tempScanDir ).Msg ("Created temporary directory" )
107107
108- projects , pwarn := s .getProjectList (locations )
108+ projects , pwarn := s .getProjectList (locations , ignored )
109109 if pwarn != nil {
110110 pwarn = errors .Join (errors .New ("errors occured when getting project list" ), pwarn )
111111 warn = errors .Join (pwarn , warn )
@@ -144,7 +144,18 @@ func (s *sheriffService) scanAndGetReports(locations []config.ProjectLocation) (
144144 return
145145}
146146
147- func (s * sheriffService ) getProjectList (locs []config.ProjectLocation ) (projects []repository.Project , warn error ) {
147+ func (s * sheriffService ) getProjectList (locs []config.ProjectLocation , ignored []config.ProjectLocation ) (projects []repository.Project , warn error ) {
148+ // Filter out locations that are in the ignored list
149+ locs = pie .Filter (locs , func (loc config.ProjectLocation ) bool {
150+ return ! slices .ContainsFunc (ignored , func (ignoredPath config.ProjectLocation ) bool {
151+ ignore := ignoredPath .Path == loc .Path && ignoredPath .Type == loc .Type
152+ if ignore {
153+ log .Info ().Str ("path" , loc .Path ).Msg ("Ignoring project location as it is in the ignored list" )
154+ }
155+ return ignore
156+ })
157+ })
158+
148159 gitlabLocs := pie .Map (
149160 pie .Filter (locs , func (loc config.ProjectLocation ) bool { return loc .Type == repository .Gitlab }),
150161 func (loc config.ProjectLocation ) string { return loc .Path },
0 commit comments