2023-01-06 05:44:37 +00:00
|
|
|
package engine
|
|
|
|
|
|
|
|
import (
|
|
|
|
"runtime"
|
|
|
|
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
|
|
"google.golang.org/protobuf/types/known/anypb"
|
|
|
|
|
|
|
|
"github.com/trufflesecurity/trufflehog/v3/pkg/context"
|
|
|
|
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/sourcespb"
|
|
|
|
"github.com/trufflesecurity/trufflehog/v3/pkg/sources/circleci"
|
|
|
|
)
|
|
|
|
|
2023-01-17 17:36:18 +00:00
|
|
|
// ScanCircleCI scans CircleCI logs.
|
2023-01-06 05:44:37 +00:00
|
|
|
func (e *Engine) ScanCircleCI(ctx context.Context, token string) error {
|
|
|
|
connection := &sourcespb.CircleCI{
|
|
|
|
Credential: &sourcespb.CircleCI_Token{
|
|
|
|
Token: token,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
var conn anypb.Any
|
|
|
|
err := anypb.MarshalFrom(&conn, connection, proto.MarshalOptions{})
|
|
|
|
if err != nil {
|
2023-02-09 22:55:19 +00:00
|
|
|
ctx.Logger().Error(err, "failed to marshal Circle CI connection")
|
2023-01-06 05:44:37 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2023-09-12 23:58:38 +00:00
|
|
|
sourceName := "trufflehog - Circle CI"
|
2023-09-13 00:23:25 +00:00
|
|
|
sourceID, jobID, _ := e.sourceManager.GetIDs(ctx, sourceName, circleci.SourceType)
|
2023-09-12 23:58:38 +00:00
|
|
|
|
|
|
|
circleSource := &circleci.Source{}
|
|
|
|
if err := circleSource.Init(ctx, "trufflehog - Circle CI", int64(jobID), int64(sourceID), true, &conn, runtime.NumCPU()); err != nil {
|
2023-08-03 18:36:30 +00:00
|
|
|
return err
|
2023-01-06 05:44:37 +00:00
|
|
|
}
|
2023-09-12 23:58:38 +00:00
|
|
|
_, err = e.sourceManager.Run(ctx, sourceName, circleSource)
|
2023-08-03 18:36:30 +00:00
|
|
|
return err
|
2023-01-06 05:44:37 +00:00
|
|
|
}
|