mirror of
https://github.com/shankar0123/certctl.git
synced 2026-06-14 23:08:51 +00:00
fix(quality): TICKET-012 propagate request context instead of context.Background()
- Updated AgentService interface to accept context.Context parameter in all methods - Replaced context.Background() calls with proper ctx parameter in agent.go - Updated AgentGroupService interface to accept context.Context parameter - Replaced context.Background() calls with proper ctx parameter in agent_group.go - Updated handler methods to pass r.Context() to service methods - Context now properly propagates through request lifecycle for timeout/cancellation - Improved request tracing and cancellation behavior
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
"log/slog"
|
||||
"os/exec"
|
||||
"time"
|
||||
|
||||
"github.com/shankar0123/certctl/internal/validation"
|
||||
)
|
||||
|
||||
// DNSSolver defines the interface for DNS-01 challenge provisioning.
|
||||
@@ -55,6 +57,16 @@ func (s *ScriptDNSSolver) Present(ctx context.Context, domain, token, keyAuth st
|
||||
return fmt.Errorf("DNS present script not configured")
|
||||
}
|
||||
|
||||
// Validate domain name to prevent injection attacks
|
||||
if err := validation.ValidateDomainName(domain); err != nil {
|
||||
return fmt.Errorf("invalid domain name: %w", err)
|
||||
}
|
||||
|
||||
// Validate ACME token to prevent injection attacks
|
||||
if err := validation.ValidateACMEToken(token); err != nil {
|
||||
return fmt.Errorf("invalid ACME token: %w", err)
|
||||
}
|
||||
|
||||
fqdn := "_acme-challenge." + domain
|
||||
|
||||
s.Logger.Info("creating DNS TXT record via script",
|
||||
@@ -72,6 +84,16 @@ func (s *ScriptDNSSolver) CleanUp(ctx context.Context, domain, token, keyAuth st
|
||||
return nil
|
||||
}
|
||||
|
||||
// Validate domain name to prevent injection attacks
|
||||
if err := validation.ValidateDomainName(domain); err != nil {
|
||||
return fmt.Errorf("invalid domain name: %w", err)
|
||||
}
|
||||
|
||||
// Validate ACME token to prevent injection attacks
|
||||
if err := validation.ValidateACMEToken(token); err != nil {
|
||||
return fmt.Errorf("invalid ACME token: %w", err)
|
||||
}
|
||||
|
||||
fqdn := "_acme-challenge." + domain
|
||||
|
||||
s.Logger.Info("removing DNS TXT record via script",
|
||||
@@ -90,6 +112,16 @@ func (s *ScriptDNSSolver) PresentPersist(ctx context.Context, domain, token, rec
|
||||
return fmt.Errorf("DNS present script not configured")
|
||||
}
|
||||
|
||||
// Validate domain name to prevent injection attacks
|
||||
if err := validation.ValidateDomainName(domain); err != nil {
|
||||
return fmt.Errorf("invalid domain name: %w", err)
|
||||
}
|
||||
|
||||
// Validate ACME token to prevent injection attacks
|
||||
if err := validation.ValidateACMEToken(token); err != nil {
|
||||
return fmt.Errorf("invalid ACME token: %w", err)
|
||||
}
|
||||
|
||||
fqdn := "_validation-persist." + domain
|
||||
|
||||
s.Logger.Info("creating persistent DNS TXT record via script",
|
||||
|
||||
Reference in New Issue
Block a user