 131868bdca
			
		
	
	131868bdca
	
	
	
		
			
			Major security, observability, and configuration improvements:
## Security Hardening
- Implemented configurable CORS (no more wildcards)
- Added comprehensive auth middleware for admin endpoints
- Enhanced webhook HMAC validation
- Added input validation and rate limiting
- Security headers and CSP policies
## Configuration Management
- Made N8N webhook URL configurable (WHOOSH_N8N_BASE_URL)
- Replaced all hardcoded endpoints with environment variables
- Added feature flags for LLM vs heuristic composition
- Gitea fetch hardening with EAGER_FILTER and FULL_RESCAN options
## API Completeness
- Implemented GetCouncilComposition function
- Added GET /api/v1/councils/{id} endpoint
- Council artifacts API (POST/GET /api/v1/councils/{id}/artifacts)
- /admin/health/details endpoint with component status
- Database lookup for repository URLs (no hardcoded fallbacks)
## Observability & Performance
- Added OpenTelemetry distributed tracing with goal/pulse correlation
- Performance optimization database indexes
- Comprehensive health monitoring
- Enhanced logging and error handling
## Infrastructure
- Production-ready P2P discovery (replaces mock implementation)
- Removed unused Redis configuration
- Enhanced Docker Swarm integration
- Added migration files for performance indexes
## Code Quality
- Comprehensive input validation
- Graceful error handling and failsafe fallbacks
- Backwards compatibility maintained
- Following security best practices
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
		
	
		
			
				
	
	
		
			107 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			107 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright The OpenTelemetry Authors
 | |
| //
 | |
| // Licensed under the Apache License, Version 2.0 (the "License");
 | |
| // you may not use this file except in compliance with the License.
 | |
| // You may obtain a copy of the License at
 | |
| //
 | |
| //     http://www.apache.org/licenses/LICENSE-2.0
 | |
| //
 | |
| // Unless required by applicable law or agreed to in writing, software
 | |
| // distributed under the License is distributed on an "AS IS" BASIS,
 | |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
| // See the License for the specific language governing permissions and
 | |
| // limitations under the License.
 | |
| 
 | |
| package resource // import "go.opentelemetry.io/otel/sdk/resource"
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 	"fmt"
 | |
| 	"net/url"
 | |
| 	"os"
 | |
| 	"strings"
 | |
| 
 | |
| 	"go.opentelemetry.io/otel"
 | |
| 	"go.opentelemetry.io/otel/attribute"
 | |
| 	semconv "go.opentelemetry.io/otel/semconv/v1.24.0"
 | |
| )
 | |
| 
 | |
| const (
 | |
| 	// resourceAttrKey is the environment variable name OpenTelemetry Resource information will be read from.
 | |
| 	resourceAttrKey = "OTEL_RESOURCE_ATTRIBUTES" //nolint:gosec // False positive G101: Potential hardcoded credentials
 | |
| 
 | |
| 	// svcNameKey is the environment variable name that Service Name information will be read from.
 | |
| 	svcNameKey = "OTEL_SERVICE_NAME"
 | |
| )
 | |
| 
 | |
| // errMissingValue is returned when a resource value is missing.
 | |
| var errMissingValue = fmt.Errorf("%w: missing value", ErrPartialResource)
 | |
| 
 | |
| // fromEnv is a Detector that implements the Detector and collects
 | |
| // resources from environment.  This Detector is included as a
 | |
| // builtin.
 | |
| type fromEnv struct{}
 | |
| 
 | |
| // compile time assertion that FromEnv implements Detector interface.
 | |
| var _ Detector = fromEnv{}
 | |
| 
 | |
| // Detect collects resources from environment.
 | |
| func (fromEnv) Detect(context.Context) (*Resource, error) {
 | |
| 	attrs := strings.TrimSpace(os.Getenv(resourceAttrKey))
 | |
| 	svcName := strings.TrimSpace(os.Getenv(svcNameKey))
 | |
| 
 | |
| 	if attrs == "" && svcName == "" {
 | |
| 		return Empty(), nil
 | |
| 	}
 | |
| 
 | |
| 	var res *Resource
 | |
| 
 | |
| 	if svcName != "" {
 | |
| 		res = NewSchemaless(semconv.ServiceName(svcName))
 | |
| 	}
 | |
| 
 | |
| 	r2, err := constructOTResources(attrs)
 | |
| 
 | |
| 	// Ensure that the resource with the service name from OTEL_SERVICE_NAME
 | |
| 	// takes precedence, if it was defined.
 | |
| 	res, err2 := Merge(r2, res)
 | |
| 
 | |
| 	if err == nil {
 | |
| 		err = err2
 | |
| 	} else if err2 != nil {
 | |
| 		err = fmt.Errorf("detecting resources: %s", []string{err.Error(), err2.Error()})
 | |
| 	}
 | |
| 
 | |
| 	return res, err
 | |
| }
 | |
| 
 | |
| func constructOTResources(s string) (*Resource, error) {
 | |
| 	if s == "" {
 | |
| 		return Empty(), nil
 | |
| 	}
 | |
| 	pairs := strings.Split(s, ",")
 | |
| 	var attrs []attribute.KeyValue
 | |
| 	var invalid []string
 | |
| 	for _, p := range pairs {
 | |
| 		k, v, found := strings.Cut(p, "=")
 | |
| 		if !found {
 | |
| 			invalid = append(invalid, p)
 | |
| 			continue
 | |
| 		}
 | |
| 		key := strings.TrimSpace(k)
 | |
| 		val, err := url.PathUnescape(strings.TrimSpace(v))
 | |
| 		if err != nil {
 | |
| 			// Retain original value if decoding fails, otherwise it will be
 | |
| 			// an empty string.
 | |
| 			val = v
 | |
| 			otel.Handle(err)
 | |
| 		}
 | |
| 		attrs = append(attrs, attribute.String(key, val))
 | |
| 	}
 | |
| 	var err error
 | |
| 	if len(invalid) > 0 {
 | |
| 		err = fmt.Errorf("%w: %v", errMissingValue, invalid)
 | |
| 	}
 | |
| 	return NewSchemaless(attrs...), err
 | |
| }
 |