File tree 1 file changed +15
-1
lines changed
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -19,13 +19,27 @@ import (
19
19
)
20
20
21
21
func PrintLegacyJSON (r * detectors.ResultWithMetadata ) {
22
- repoPath , remote , err := git .PrepareRepo (r .SourceMetadata .GetGithub ().Repository )
22
+ var repo string
23
+ switch r .SourceType {
24
+ case sourcespb .SourceType_SOURCE_TYPE_GIT :
25
+ repo = r .SourceMetadata .GetGit ().Repository
26
+ case sourcespb .SourceType_SOURCE_TYPE_GITHUB :
27
+ repo = r .SourceMetadata .GetGithub ().Repository
28
+ case sourcespb .SourceType_SOURCE_TYPE_GITLAB :
29
+ repo = r .SourceMetadata .GetGitlab ().Repository
30
+ default :
31
+ logrus .Errorf ("unsupported source type for legacy json output: %s" , r .SourceType )
32
+ }
33
+
34
+ // cloning the repo again here is not great and only works with unauthed repos
35
+ repoPath , remote , err := git .PrepareRepo (repo )
23
36
if err != nil || repoPath == "" {
24
37
logrus .WithError (err ).Fatal ("error preparing git repo for scanning" )
25
38
}
26
39
if remote {
27
40
defer os .RemoveAll (repoPath )
28
41
}
42
+
29
43
legacy := ConvertToLegacyJSON (r , repoPath )
30
44
out , err := json .Marshal (legacy )
31
45
if err != nil {
You can’t perform that action at this time.
0 commit comments