fix: resolve Phase 14 merge conflicts across CI/CD, archive, and frontend sources
This commit is contained in:
@@ -4,14 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
<<<<<<< HEAD
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
=======
|
||||
"io"
|
||||
"net/http"
|
||||
>>>>>>> worktree-agent-adad8c10
|
||||
"time"
|
||||
|
||||
"golang.org/x/time/rate"
|
||||
@@ -21,56 +15,19 @@ import (
|
||||
)
|
||||
|
||||
// GitHubActionsSource searches GitHub Actions workflow run logs for leaked API
|
||||
<<<<<<< HEAD
|
||||
// keys. It queries the GitHub REST API for workflow runs matching provider
|
||||
// keywords (via the repository search endpoint) and emits findings for each
|
||||
// matching run. Requires a GitHub token (same as GitHubSource).
|
||||
=======
|
||||
// keys. Workflow logs are public for public repositories and frequently contain
|
||||
// accidentally printed secrets, debug output with credentials, or insecure
|
||||
// echo statements that expose environment variables.
|
||||
>>>>>>> worktree-agent-adad8c10
|
||||
type GitHubActionsSource struct {
|
||||
Token string
|
||||
BaseURL string
|
||||
Registry *providers.Registry
|
||||
Limiters *recon.LimiterRegistry
|
||||
<<<<<<< HEAD
|
||||
client *Client
|
||||
=======
|
||||
Client *Client
|
||||
>>>>>>> worktree-agent-adad8c10
|
||||
}
|
||||
|
||||
var _ recon.ReconSource = (*GitHubActionsSource)(nil)
|
||||
|
||||
<<<<<<< HEAD
|
||||
func (s *GitHubActionsSource) Name() string { return "github_actions" }
|
||||
func (s *GitHubActionsSource) RateLimit() rate.Limit { return rate.Every(2 * time.Second) }
|
||||
func (s *GitHubActionsSource) Burst() int { return 2 }
|
||||
func (s *GitHubActionsSource) RespectsRobots() bool { return false }
|
||||
func (s *GitHubActionsSource) Enabled(_ recon.Config) bool { return s.Token != "" }
|
||||
|
||||
// ghActionsSearchResponse models the GitHub code search response when looking
|
||||
// for workflow files containing provider keywords.
|
||||
type ghActionsSearchResponse struct {
|
||||
Items []ghActionsItem `json:"items"`
|
||||
}
|
||||
|
||||
type ghActionsItem struct {
|
||||
HTMLURL string `json:"html_url"`
|
||||
Repository ghActionsRepository `json:"repository"`
|
||||
}
|
||||
|
||||
type ghActionsRepository struct {
|
||||
FullName string `json:"full_name"`
|
||||
}
|
||||
|
||||
func (s *GitHubActionsSource) Sweep(ctx context.Context, _ string, out chan<- recon.Finding) error {
|
||||
if s.Token == "" {
|
||||
return nil
|
||||
}
|
||||
=======
|
||||
func (s *GitHubActionsSource) Name() string { return "ghactions" }
|
||||
func (s *GitHubActionsSource) RateLimit() rate.Limit { return rate.Every(2 * time.Second) }
|
||||
func (s *GitHubActionsSource) Burst() int { return 3 }
|
||||
@@ -93,19 +50,10 @@ type ghActionsRun struct {
|
||||
}
|
||||
|
||||
func (s *GitHubActionsSource) Sweep(ctx context.Context, _ string, out chan<- recon.Finding) error {
|
||||
>>>>>>> worktree-agent-adad8c10
|
||||
base := s.BaseURL
|
||||
if base == "" {
|
||||
base = "https://api.github.com"
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
if s.client == nil {
|
||||
s.client = NewClient()
|
||||
}
|
||||
|
||||
queries := BuildQueries(s.Registry, "github_actions")
|
||||
kwIndex := ghActionsKeywordIndex(s.Registry)
|
||||
=======
|
||||
client := s.Client
|
||||
if client == nil {
|
||||
client = NewClient()
|
||||
@@ -115,62 +63,18 @@ func (s *GitHubActionsSource) Sweep(ctx context.Context, _ string, out chan<- re
|
||||
if len(queries) == 0 {
|
||||
return nil
|
||||
}
|
||||
>>>>>>> worktree-agent-adad8c10
|
||||
|
||||
for _, q := range queries {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
>>>>>>> worktree-agent-adad8c10
|
||||
if s.Limiters != nil {
|
||||
if err := s.Limiters.Wait(ctx, s.Name(), s.RateLimit(), s.Burst(), false); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
// Search for workflow YAML files referencing the keyword.
|
||||
endpoint := fmt.Sprintf("%s/search/code?q=%s+path:.github/workflows+extension:yml&per_page=20",
|
||||
base, url.QueryEscape(q))
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("github_actions: build request: %w", err)
|
||||
}
|
||||
req.Header.Set("Authorization", "Bearer "+s.Token)
|
||||
req.Header.Set("Accept", "application/vnd.github+json")
|
||||
|
||||
resp, err := s.client.Do(ctx, req)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "unauthorized") {
|
||||
return err
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
var result ghActionsSearchResponse
|
||||
decErr := json.NewDecoder(resp.Body).Decode(&result)
|
||||
_ = resp.Body.Close()
|
||||
if decErr != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
provName := kwIndex[strings.ToLower(q)]
|
||||
for _, item := range result.Items {
|
||||
f := recon.Finding{
|
||||
ProviderName: provName,
|
||||
Confidence: "low",
|
||||
Source: item.HTMLURL,
|
||||
SourceType: "recon:github_actions",
|
||||
DetectedAt: time.Now(),
|
||||
}
|
||||
select {
|
||||
case out <- f:
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
=======
|
||||
// Search for workflow runs via the Actions API.
|
||||
searchURL := fmt.Sprintf("%s/search/code?q=%s+path:.github/workflows", base, q)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, searchURL, nil)
|
||||
@@ -231,30 +135,8 @@ func (s *GitHubActionsSource) Sweep(ctx context.Context, _ string, out chan<- re
|
||||
Confidence: "medium",
|
||||
DetectedAt: time.Now(),
|
||||
}
|
||||
>>>>>>> worktree-agent-adad8c10
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
func ghActionsKeywordIndex(reg *providers.Registry) map[string]string {
|
||||
m := make(map[string]string)
|
||||
if reg == nil {
|
||||
return m
|
||||
}
|
||||
for _, p := range reg.List() {
|
||||
for _, k := range p.Keywords {
|
||||
kl := strings.ToLower(strings.TrimSpace(k))
|
||||
if kl != "" {
|
||||
if _, exists := m[kl]; !exists {
|
||||
m[kl] = p.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return m
|
||||
}
|
||||
=======
|
||||
>>>>>>> worktree-agent-adad8c10
|
||||
|
||||
Reference in New Issue
Block a user