Skip to content

Commit

Permalink
fix(api): protect api from bad interpolation sequences from git info (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
fsamin authored Sep 20, 2021
1 parent ef9d729 commit ed59ae3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions engine/api/workflow/process_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,20 @@ func processNode(ctx context.Context, db gorpmapper.SqlExecutorWithTx, store cac
}
}

// Replace ("{{ }}" in vcsInfo that should be badly interpreted by interpolation engine)
var repl = func(s *string) {
*s = strings.ReplaceAll(*s, "{{", "((")
*s = strings.ReplaceAll(*s, "}}", "))")
}

// Update git params / git columns
if isRoot && vcsInf != nil {
repl(&vcsInf.Author)
repl(&vcsInf.Branch)
repl(&vcsInf.Hash)
repl(&vcsInf.Message)
repl(&vcsInf.Tag)

setValuesGitInBuildParameters(nr, *vcsInf)
}

Expand Down Expand Up @@ -281,6 +293,12 @@ func processNode(ctx context.Context, db gorpmapper.SqlExecutorWithTx, store cac

// Update datas if repo change
if !isRoot && vcsInf != nil {
repl(&vcsInf.Author)
repl(&vcsInf.Branch)
repl(&vcsInf.Hash)
repl(&vcsInf.Message)
repl(&vcsInf.Tag)

setValuesGitInBuildParameters(nr, *vcsInf)
}

Expand Down

0 comments on commit ed59ae3

Please sign in to comment.