fix: resolve Phase 14 merge conflicts across CI/CD, archive, and frontend sources
This commit is contained in:
@@ -4,13 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
<<<<<<< HEAD
|
||||
"net/http"
|
||||
"strings"
|
||||
=======
|
||||
"io"
|
||||
"net/http"
|
||||
>>>>>>> worktree-agent-adad8c10
|
||||
"time"
|
||||
|
||||
"golang.org/x/time/rate"
|
||||
@@ -19,17 +14,10 @@ import (
|
||||
"github.com/salvacybersec/keyhunter/pkg/recon"
|
||||
)
|
||||
|
||||
<<<<<<< HEAD
|
||||
// JenkinsSource searches publicly accessible Jenkins instances for build
|
||||
// console output containing leaked API keys. It queries the Jenkins JSON API
|
||||
// at /api/json to enumerate jobs and their latest builds. Credentialless --
|
||||
// targets open Jenkins instances discovered via dorking or IoT scanners.
|
||||
=======
|
||||
// JenkinsSource scrapes publicly accessible Jenkins build consoles for leaked
|
||||
// API keys. Many Jenkins instances are exposed to the internet without
|
||||
// authentication, and build console output frequently contains printed
|
||||
// environment variables or secrets passed via command-line arguments.
|
||||
>>>>>>> worktree-agent-adad8c10
|
||||
type JenkinsSource struct {
|
||||
BaseURL string
|
||||
Registry *providers.Registry
|
||||
@@ -39,14 +27,6 @@ type JenkinsSource struct {
|
||||
|
||||
var _ recon.ReconSource = (*JenkinsSource)(nil)
|
||||
|
||||
<<<<<<< HEAD
|
||||
func (s *JenkinsSource) Name() string { return "jenkins" }
|
||||
func (s *JenkinsSource) RateLimit() rate.Limit { return rate.Every(3 * time.Second) }
|
||||
func (s *JenkinsSource) Burst() int { return 1 }
|
||||
func (s *JenkinsSource) RespectsRobots() bool { return true }
|
||||
func (s *JenkinsSource) Enabled(_ recon.Config) bool { return true }
|
||||
|
||||
=======
|
||||
func (s *JenkinsSource) Name() string { return "jenkins" }
|
||||
func (s *JenkinsSource) RateLimit() rate.Limit { return rate.Every(3 * time.Second) }
|
||||
func (s *JenkinsSource) Burst() int { return 2 }
|
||||
@@ -54,36 +34,20 @@ func (s *JenkinsSource) RespectsRobots() bool { return true }
|
||||
func (s *JenkinsSource) Enabled(_ recon.Config) bool { return true }
|
||||
|
||||
// jenkinsJobsResponse represents the Jenkins API jobs listing.
|
||||
>>>>>>> worktree-agent-adad8c10
|
||||
type jenkinsJobsResponse struct {
|
||||
Jobs []jenkinsJob `json:"jobs"`
|
||||
}
|
||||
|
||||
type jenkinsJob struct {
|
||||
<<<<<<< HEAD
|
||||
Name string `json:"name"`
|
||||
URL string `json:"url"`
|
||||
LastBuild *jenkinsBuild `json:"lastBuild"`
|
||||
}
|
||||
|
||||
type jenkinsBuild struct {
|
||||
Number int `json:"number"`
|
||||
URL string `json:"url"`
|
||||
=======
|
||||
Name string `json:"name"`
|
||||
URL string `json:"url"`
|
||||
Color string `json:"color"`
|
||||
>>>>>>> worktree-agent-adad8c10
|
||||
}
|
||||
|
||||
func (s *JenkinsSource) Sweep(ctx context.Context, _ string, out chan<- recon.Finding) error {
|
||||
base := s.BaseURL
|
||||
if base == "" {
|
||||
<<<<<<< HEAD
|
||||
base = "https://jenkins.example.com"
|
||||
=======
|
||||
return nil // No default; Jenkins instances are discovered via dorking
|
||||
>>>>>>> worktree-agent-adad8c10
|
||||
}
|
||||
client := s.Client
|
||||
if client == nil {
|
||||
@@ -91,40 +55,26 @@ func (s *JenkinsSource) Sweep(ctx context.Context, _ string, out chan<- recon.Fi
|
||||
}
|
||||
|
||||
queries := BuildQueries(s.Registry, "jenkins")
|
||||
<<<<<<< HEAD
|
||||
kwIndex := jenkinsKeywordIndex(s.Registry)
|
||||
=======
|
||||
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
|
||||
endpoint := fmt.Sprintf("%s/api/json?tree=jobs[name,url,lastBuild[number,url]]", base)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("jenkins: build request: %w", err)
|
||||
=======
|
||||
// List jobs from the Jenkins API.
|
||||
jobsURL := fmt.Sprintf("%s/api/json?tree=jobs[name,url,color]", base)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, jobsURL, nil)
|
||||
if err != nil {
|
||||
continue
|
||||
>>>>>>> worktree-agent-adad8c10
|
||||
}
|
||||
req.Header.Set("Accept", "application/json")
|
||||
|
||||
@@ -133,35 +83,6 @@ func (s *JenkinsSource) Sweep(ctx context.Context, _ string, out chan<- recon.Fi
|
||||
continue
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
var result jenkinsJobsResponse
|
||||
decErr := json.NewDecoder(resp.Body).Decode(&result)
|
||||
_ = resp.Body.Close()
|
||||
if decErr != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
provName := kwIndex[strings.ToLower(q)]
|
||||
for _, job := range result.Jobs {
|
||||
if job.LastBuild == nil {
|
||||
continue
|
||||
}
|
||||
source := job.LastBuild.URL
|
||||
if source == "" {
|
||||
source = fmt.Sprintf("%s/job/%s/%d/console", base, job.Name, job.LastBuild.Number)
|
||||
}
|
||||
f := recon.Finding{
|
||||
ProviderName: provName,
|
||||
Confidence: "low",
|
||||
Source: source,
|
||||
SourceType: "recon:jenkins",
|
||||
DetectedAt: time.Now(),
|
||||
}
|
||||
select {
|
||||
case out <- f:
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
=======
|
||||
var jobs jenkinsJobsResponse
|
||||
if err := json.NewDecoder(resp.Body).Decode(&jobs); err != nil {
|
||||
_ = resp.Body.Close()
|
||||
@@ -206,30 +127,8 @@ func (s *JenkinsSource) Sweep(ctx context.Context, _ string, out chan<- recon.Fi
|
||||
Confidence: "medium",
|
||||
DetectedAt: time.Now(),
|
||||
}
|
||||
>>>>>>> worktree-agent-adad8c10
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
func jenkinsKeywordIndex(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