Preuve · code, extrait

connections.go

Dépôt apteva/server · commit b1d72aa5f0326d40536b7cdd280733edeb9a285b · plateforme Apteva, serveur, clone du 13 septembre 2026

Extrait tel qu'à ce commit : lignes 2556–2621, sur 3 774 (numérotation d'origine, 30 lignes de contexte autour de chaque citation) · fichier intégral sur GitHub (dépôt public)

Lignes citées par l'audit : 2586–2591

66 lignes reproduites · ← retour à l'audit · catalogue des preuves

2556		if _, ok := data.(map[string]any); !ok {
2557			return integrationResponseContractFailure(
2558				resp.StatusCode,
2559				hdrs,
2560				"Expected a JSON object containing response_path "+path,
2561			), nil
2562		}
2563		extracted, found := lookupIntegrationResponsePath(data, path)
2564		if !found || extracted == nil {
2565			return integrationResponseContractFailure(
2566				resp.StatusCode,
2567				hdrs,
2568				"Missing response_path "+path,
2569			), nil
2570		}
2571		data = extracted
2572	}
2573
2574	if tool.ResponseTransform != nil && data != nil && !binary {
2575		transformed, _, err := buildResponseTransformData(tool.ResponseTransform, data, input)
2576		if err != nil {
2577			return nil, err
2578		}
2579		data = transformed
2580	}
2581
2582	// Strip any fields the tool declared we shouldn't expose. Runs
2583	// AFTER response_path so the paths are relative to whatever the
2584	// agent actually ends up seeing. Silent no-op on unmatched paths
2585	// so a minor upstream schema drift doesn't break the tool.
2586	if len(tool.ResponseOmit) > 0 && data != nil {
2587		for _, p := range tool.ResponseOmit {
2588			data = omitPath(data, p)
2589		}
2590	}
2591
2592	return &ExecuteResult{
2593		Success: resp.StatusCode >= 200 && resp.StatusCode < 300,
2594		Status:  resp.StatusCode,
2595		Data:    data,
2596		Headers: hdrs,
2597	}, nil
2598}
2599
2600func applyCredentialFieldDefaults(app *AppTemplate, credentials map[string]string) map[string]string {
2601	if credentials == nil {
2602		credentials = make(map[string]string)
2603	}
2604	if app == nil {
2605		return credentials
2606	}
2607	for _, field := range app.Auth.CredentialFields {
2608		if strings.TrimSpace(credentials[field.Name]) == "" && field.Default != "" {
2609			credentials[field.Name] = field.Default
2610		}
2611	}
2612	return credentials
2613}
2614
2615func environmentIntegrationMode(environmentID string) string {
2616	if environmentID == "" {
2617		return IntegrationModeReal
2618	}
2619	if v, ok := environmentIntegrationModes.Load(environmentID); ok {
2620		if mode, ok := v.(string); ok && mode != "" {
2621			return normalizeEnvironmentIntegrationMode(mode, "")