Documentation
¶
Overview ¶
File: ./utils/Utils.go
Index ¶
- Constants
- Variables
- func Contains[T comparable](slice []T, element T) bool
- func CountFiles(dirPath string) (int, error)
- func DeleteDatabaseFileIfExists(path string) error
- func DumpSQLiteSchemaForFindings(db_file string)
- func ExtractRepoName(repoURL string) (string, error)
- func GenerateRandomFilename(extension string) string
- func GetStructName(i interface{}) string
- func InitializeSQLiteDB(dbPath string) (*sql.DB, error)
- func InsertMatches(db *sql.DB, matches []core.Finding) (err error)
- func Sanitize(name string) string
- func SanitizeRepoName(fullName string) string
- type BarProgressReporter
- type CloneOptionsBuilder
- type Cloner
- type GitApi
- type GitApiClient
- type GitCloneInfo
- type GitMetrics
- type GitMetricsClient
- type GithubApi
- type GithubApiClient
- type GitlabApi
- type GitlabApiClient
- type MockMatchIterator
- type MockMatchRepository
- type ProgressReporter
Constants ¶
const BucketName = "Projects"
const CacheDirName = ".techdetector_cache"
Variables ¶
var PredefinedFieldsSlice = []string{"Name", "Type", "Category", "Path", "RepoName"}
PredefinedFieldsSlice contains the fields that always go in the findings table
Functions ¶
func Contains ¶
func Contains[T comparable](slice []T, element T) bool
func CountFiles ¶
func DeleteDatabaseFileIfExists ¶ added in v0.8.0
func DumpSQLiteSchemaForFindings ¶ added in v0.8.0
func DumpSQLiteSchemaForFindings(db_file string)
func ExtractRepoName ¶
func GenerateRandomFilename ¶
func GetStructName ¶ added in v0.8.0
func GetStructName(i interface{}) string
func InitializeSQLiteDB ¶ added in v0.8.0
InitializeSQLiteDB opens (or creates) the SQLite DB, applies a schema for findings, and optionally turns on performance PRAGMAs for faster bulk inserts.
func InsertMatches ¶ added in v0.8.0
func SanitizeRepoName ¶
Types ¶
type BarProgressReporter ¶ added in v0.8.0
type BarProgressReporter struct {
// contains filtered or unexported fields
}
BarProgressReporter is a concrete implementation using progressbar.
func NewBarProgressReporter ¶ added in v0.8.0
func NewBarProgressReporter(total int, description string) *BarProgressReporter
NewBarProgressReporter creates a new BarProgressReporter with the given total and description.
func (*BarProgressReporter) Finish ¶ added in v0.8.0
func (p *BarProgressReporter) Finish()
func (*BarProgressReporter) Increment ¶ added in v0.8.0
func (p *BarProgressReporter) Increment()
Increment increases the progress bar by one.
func (*BarProgressReporter) SetTotal ¶ added in v0.8.0
func (p *BarProgressReporter) SetTotal(total int)
SetTotal reinitializes the progress bar with the new total count.
type CloneOptionsBuilder ¶ added in v0.8.0
type CloneOptionsBuilder struct {
// contains filtered or unexported fields
}
func NewCloneOptionsBuilder ¶ added in v0.8.0
func NewCloneOptionsBuilder(ctx context.Context, cloneURL, destination string) *CloneOptionsBuilder
func (*CloneOptionsBuilder) Clone ¶ added in v0.8.0
func (b *CloneOptionsBuilder) Clone() error
func (*CloneOptionsBuilder) WithBare ¶ added in v0.8.0
func (b *CloneOptionsBuilder) WithBare(bare bool) Cloner
func (*CloneOptionsBuilder) WithToken ¶ added in v0.8.0
func (b *CloneOptionsBuilder) WithToken(token string) Cloner
type GitApiClient ¶ added in v0.8.0
type GitApiClient struct{}
func (GitApiClient) Clone ¶ added in v0.8.0
func (g GitApiClient) Clone(cloneBaseDir, repoUrl string) (*GitCloneInfo, error)
func (GitApiClient) CloneRepositoryWithContext ¶ added in v0.8.0
type GitCloneInfo ¶ added in v0.8.0
type GitMetrics ¶ added in v0.8.0
type GitMetrics interface {
CollectGitMetrics(repoPath, repoName, cutoffDate string) ([]core.Finding, error)
}
GitMetrics defines the behavior for collecting Git metrics.
type GitMetricsClient ¶ added in v0.8.0
type GitMetricsClient struct{}
GitMetricsClient is the default implementation of GitMetrics.
func (GitMetricsClient) CollectGitMetrics ¶ added in v0.8.0
func (g GitMetricsClient) CollectGitMetrics(repoPath, repoName, cutoffDate string) ([]core.Finding, error)
CollectGitMetrics collects various Git metrics from the repository.
type GithubApi ¶ added in v0.8.0
type GithubApi interface {
ListRepositories(org string) ([]*github.Repository, error)
}
type GithubApiClient ¶ added in v0.8.0
type GithubApiClient struct {
// contains filtered or unexported fields
}
func NewGithubApiClient ¶ added in v0.8.0
func NewGithubApiClient() GithubApiClient
func (GithubApiClient) ListRepositories ¶ added in v0.8.0
func (apiClient GithubApiClient) ListRepositories(org string) ([]*github.Repository, error)
type GitlabApiClient ¶ added in v0.8.0
type GitlabApiClient struct {
// contains filtered or unexported fields
}
func NewGitlabApiClient ¶ added in v0.8.0
func NewGitlabApiClient(gitlabToken string, gitlabBaseURL string, noCache bool) *GitlabApiClient
func (GitlabApiClient) BaseURL ¶ added in v0.8.0
func (g GitlabApiClient) BaseURL() string
func (GitlabApiClient) ListAllProjects ¶ added in v0.8.0
func (g GitlabApiClient) ListAllProjects() ([]*gitlab.Project, error)
func (GitlabApiClient) Token ¶ added in v0.8.0
func (g GitlabApiClient) Token() string
type MockMatchIterator ¶ added in v0.8.0
type MockMatchIterator struct {
// contains filtered or unexported fields
}
MockMatchIterator is a mock implementation of core.FindingIterator
func (*MockMatchIterator) HasNext ¶ added in v0.8.0
func (m *MockMatchIterator) HasNext() bool
HasNext checks if there are more findings to iterate over.
func (*MockMatchIterator) Next ¶ added in v0.8.0
func (m *MockMatchIterator) Next() (core.FindingSet, error)
Next retrieves the next set of findings.
func (*MockMatchIterator) Reset ¶ added in v0.8.0
func (m *MockMatchIterator) Reset() error
Reset resets the iterator to the beginning.
type MockMatchRepository ¶ added in v0.8.0
MockMatchRepository is a mock implementation of core.FindingRepository
func (*MockMatchRepository) Clear ¶ added in v0.8.0
func (m *MockMatchRepository) Clear() error
Clear removes all findings from the repository.
func (*MockMatchRepository) Close ¶ added in v0.8.0
func (m *MockMatchRepository) Close() error
func (*MockMatchRepository) NewIterator ¶ added in v0.8.0
func (m *MockMatchRepository) NewIterator() core.FindingIterator
NewIterator returns a new MockMatchIterator for iterating over the findings.
type ProgressReporter ¶ added in v0.8.0
type ProgressReporter interface { // SetTotal reinitializes the progress bar with the new total count. SetTotal(total int) // Increment increases the progress by one. Increment() Finish() }
ProgressReporter defines methods for reporting progress.