diff --git a/cmd/cmgr/playtest.go b/cmd/cmgr/playtest.go index 60a7886..7ef53a8 100644 --- a/cmd/cmgr/playtest.go +++ b/cmd/cmgr/playtest.go @@ -98,10 +98,21 @@ func launchPortal(mgr *cmgr.Manager, iface string, port int, cid cmgr.ChallengeI w.Write([]byte(fmt.Sprintf(`
%s
`, cMeta.Description))) + artifactUrl := fmt.Sprintf("http://%s:%d/artifact/$1", iface, port) + + description := cMeta.Description + description = urlRe.ReplaceAllString(description, artifactUrl) + for lookupRe.MatchString(description) { + match := lookupRe.FindStringSubmatch(description) + description = strings.ReplaceAll( + description, + match[0], + fmt.Sprintf("%s", bMeta.LookupData[match[1]])) + } + + w.Write([]byte(fmt.Sprintf(`%s
`, description))) details := cMeta.Details - artifactUrl := fmt.Sprintf("http://%s:%d/artifact/$1", iface, port) details = urlRe.ReplaceAllString(details, artifactUrl) details = serverRe.ReplaceAllString(details, iface) details = httpBaseRe.ReplaceAllString(details, fmt.Sprintf("http://%s", iface)) diff --git a/cmgr/loader.go b/cmgr/loader.go index 91864b8..ba2eef5 100644 --- a/cmgr/loader.go +++ b/cmgr/loader.go @@ -304,8 +304,13 @@ func (m *Manager) validateMetadata(md *ChallengeMetadata) error { return s, err } - // Validate (& lift) Details - res, err := normalizeAndCheckTemplated(md.Details) + res, err := normalizeAndCheckTemplated(md.Description) + if err != nil { + lastErr = err + } + md.Description = res + + res, err = normalizeAndCheckTemplated(md.Details) if err != nil { lastErr = err } @@ -447,8 +452,12 @@ func (m *Manager) validateBuild(cMeta *ChallengeMetadata, md *BuildMetadata, fil return err } - // Validate (& lift) Details - err := checkTemplated(cMeta.Details) + // Validate templated fields + err := checkTemplated(cMeta.Description) + detailsErr := checkTemplated(cMeta.Details) + if detailsErr != nil { + err = detailsErr + } for _, hint := range cMeta.Hints { tmpErr := checkTemplated(hint)