Codescan:
- Sync claims.go reDeleteAccount with the expanded account-no-delete anti-pattern
so HasDeleteAccountCode / StaticPassed no longer drift (Vault "Close account").
- Tighten the §5.1.1 anti-pattern: drop the over-broad `account.*clos` (matched
incidental `accountClosed`) and narrow `delete.*my.*(data|account)` to account
only, so GDPR data-deletion and stray lines can't suppress a real violation.
- firstMatchOnly findings are now collapsed to one per project at the scanner
level (dedupOnceRules), not just one per file.
verify / revyl:
- Don't classify an undecided report as FAILED: if the report never finalizes,
report StatusError ("could not determine the outcome") instead of crying wolf.
- Propagate AppID resolution errors so a CLI/parse failure isn't surfaced as a
misleading "no Revyl app found".
- yamlStr escapes \n/\r/\t and `platform` is now quoted, so a --var/--platform
value with control chars can't corrupt the generated YAML.
- Authenticated() trusts the auth-status exit code instead of requiring a
specific success word (resilient to reworded/JSON output).
- extractJSON does balanced brace matching (string-aware), robust to braces in
surrounding log lines; previously first-{ to last-} could grab the wrong span.
- --var uses StringArray + a first-'=' split (parseVars) instead of pflag
StringToString, so values with commas or '==' (JWT/base64) survive intact.
cli:
- verify --format json now includes the `onboarding` field, so machine consumers
see why flows are pending.
Tests added: parseVars, extractJSON balanced, account anti-pattern tightening.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
59 lines
2.2 KiB
Go
59 lines
2.2 KiB
Go
package verify
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// renderTestYAML produces a Revyl test YAML document for a flow, matching the
|
|
// schema at https://docs.revyl.com/appendix/yaml-test-format. The test name is
|
|
// passed in (not Flow.TestName) so it can be made unique per build — a stable
|
|
// name across apps gets silently rebound to the first app's build.
|
|
//
|
|
// Credential values are inlined directly into step text rather than emitted as a
|
|
// `variables:` block: Revyl treats metadata.variables as launch-time values, and
|
|
// for apps that don't expect them the app fails to launch (the run records zero
|
|
// steps). Inlining keeps the launch clean and the steps self-contained.
|
|
func renderTestYAML(f Flow, name, platform, buildName string, vars map[string]string) string {
|
|
var b strings.Builder
|
|
b.WriteString("test:\n")
|
|
b.WriteString(" metadata:\n")
|
|
fmt.Fprintf(&b, " name: %s\n", yamlStr(name))
|
|
fmt.Fprintf(&b, " platform: %s\n", yamlStr(platform))
|
|
b.WriteString(" tags:\n")
|
|
b.WriteString(" - greenlight\n")
|
|
b.WriteString(" - runtime\n")
|
|
b.WriteString(" build:\n")
|
|
fmt.Fprintf(&b, " name: %s\n", yamlStr(buildName))
|
|
b.WriteString(" blocks:\n")
|
|
for _, s := range f.Steps {
|
|
fmt.Fprintf(&b, " - type: %s\n", s.Type)
|
|
fmt.Fprintf(&b, " step_description: %s\n", yamlStr(substituteVars(s.Desc, vars)))
|
|
if s.Type == "extraction" && s.VariableName != "" {
|
|
fmt.Fprintf(&b, " variable_name: %s\n", yamlStr(s.VariableName))
|
|
}
|
|
}
|
|
return b.String()
|
|
}
|
|
|
|
// substituteVars replaces {{key}} placeholders with their provided values.
|
|
// Unprovided placeholders are left as-is.
|
|
func substituteVars(s string, vars map[string]string) string {
|
|
for k, v := range vars {
|
|
s = strings.ReplaceAll(s, "{{"+k+"}}", v)
|
|
}
|
|
return s
|
|
}
|
|
|
|
// yamlStr returns a safely double-quoted YAML scalar. Backslashes are escaped
|
|
// first, then quotes, then control characters are converted to their escape
|
|
// sequences (a raw newline/tab/CR would otherwise terminate or corrupt the scalar).
|
|
func yamlStr(s string) string {
|
|
s = strings.ReplaceAll(s, `\`, `\\`)
|
|
s = strings.ReplaceAll(s, `"`, `\"`)
|
|
s = strings.ReplaceAll(s, "\n", `\n`)
|
|
s = strings.ReplaceAll(s, "\r", `\r`)
|
|
s = strings.ReplaceAll(s, "\t", `\t`)
|
|
return `"` + s + `"`
|
|
}
|