I16 mesh-fingerprint-refused: a manifest naming MESH_FINGERPRINT in any env is refused
Builds: design 47 H2 H-A-710 (1)
This commit is contained in:
@@ -2839,6 +2839,8 @@ func parseManifest(raw []byte, predefined catalogue.PredefinedList) (catalogue.M
|
||||
problems = append(problems, ConfigLinesProblems(m)...)
|
||||
// And the node's name, which the node-engine sets in every process's env itself (design 47 G A-342).
|
||||
problems = append(problems, NodeEnvProblems(m)...)
|
||||
// And the build's fingerprint, which the node-engine hands a service itself (design 47 H2 H-A-710 (1)).
|
||||
problems = append(problems, FingerprintEnvProblems(m)...)
|
||||
// And what it requires optionally, and the files it delivers only while bound (novox/hq ADR 0330).
|
||||
problems = append(problems, OptionalProblems(m)...)
|
||||
// And which setting keys each mergeable file takes (setting_takes.go, novox/hq ADR 0326).
|
||||
@@ -4205,6 +4207,35 @@ func NodeEnvProblems(m catalogue.Manifest) []string {
|
||||
return problems
|
||||
}
|
||||
|
||||
// FingerprintEnv is the variable the node-engine sets to the want's fingerprint in a service's env (design 47 H2 H-A-710
|
||||
// (1)): a manifest naming it in any env, a container's, a daemon's or a bundle's, is refused.
|
||||
const FingerprintEnv = "MESH_FINGERPRINT"
|
||||
|
||||
// FingerprintEnvProblems are the resources and bundles whose env names FingerprintEnv: "MESH_FINGERPRINT is the
|
||||
// node-engine's to hand".
|
||||
func FingerprintEnvProblems(m catalogue.Manifest) []string {
|
||||
var problems []string
|
||||
say := func(what string) {
|
||||
problems = append(problems, fmt.Sprintf("%s's %s names %s in its env: %s is the node-engine's to hand (design 47 H2 H-A-710)",
|
||||
m.Module, what, FingerprintEnv, FingerprintEnv))
|
||||
}
|
||||
for _, r := range m.Resources {
|
||||
if env, ok := r["env"].(map[string]any); ok {
|
||||
if _, names := env[FingerprintEnv]; names {
|
||||
say(fmt.Sprintf("resource %v", r["id"]))
|
||||
}
|
||||
}
|
||||
}
|
||||
if m.Build != nil {
|
||||
for _, a := range m.Build.Artifacts {
|
||||
if _, names := a.Env[FingerprintEnv]; names {
|
||||
say(fmt.Sprintf("artifact %q", a.Name))
|
||||
}
|
||||
}
|
||||
}
|
||||
return problems
|
||||
}
|
||||
|
||||
func filepathDir(p string) string {
|
||||
if i := strings.LastIndex(p, "/"); i > 0 {
|
||||
return p[:i]
|
||||
|
||||
@@ -2529,6 +2529,11 @@ func caseAProcessBusNamesOnlyTheModulesOwn(t *testing.T) {
|
||||
if _, err := ParseManifest([]byte(ownNode)); err == nil || !strings.Contains(err.Error(), "MESH_NODE") {
|
||||
t.Errorf("a process setting MESH_NODE itself: %v; want a refusal naming MESH_NODE", err)
|
||||
}
|
||||
// Design 47 H2 H-A-710 (1): a resource naming MESH_FINGERPRINT in its env is refused with the node-engine's-to-hand problem.
|
||||
ownFingerprint := strings.Replace(mailSenderProcessManifest(t, ""), `"user":"mesh-mail-send"}`, `"user":"mesh-mail-send","env":{"MESH_FINGERPRINT":"x"}}`, 1)
|
||||
if _, err := ParseManifest([]byte(ownFingerprint)); err == nil || !strings.Contains(err.Error(), "MESH_FINGERPRINT is the node-engine's to hand") {
|
||||
t.Errorf("a process naming MESH_FINGERPRINT itself: %v; want a refusal saying it is the node-engine's to hand", err)
|
||||
}
|
||||
// Design 47 G A-340: an event the module consumes, its process may hear.
|
||||
consumed := strings.Replace(mailSenderProcessManifest(t, `{"consumes":["billing.paid"]}`), `"resources"`, `"consumes":["billing.paid"],"resources"`, 1)
|
||||
if _, err := ParseManifest([]byte(consumed)); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user