mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-06 04:45:39 +00:00
Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
53abbbaee9
commit
e10e8127e1
@ -212,7 +212,11 @@ yq -P -oy sample.json
|
|||||||
|
|
||||||
rootCmd.PersistentFlags().BoolVarP(&yqlib.ConfiguredSecurityPreferences.DisableEnvOps, "security-disable-env-ops", "", false, "Disable env related operations.")
|
rootCmd.PersistentFlags().BoolVarP(&yqlib.ConfiguredSecurityPreferences.DisableEnvOps, "security-disable-env-ops", "", false, "Disable env related operations.")
|
||||||
rootCmd.PersistentFlags().BoolVarP(&yqlib.ConfiguredSecurityPreferences.DisableFileOps, "security-disable-file-ops", "", false, "Disable file related operations (e.g. load)")
|
rootCmd.PersistentFlags().BoolVarP(&yqlib.ConfiguredSecurityPreferences.DisableFileOps, "security-disable-file-ops", "", false, "Disable file related operations (e.g. load)")
|
||||||
rootCmd.PersistentFlags().BoolVarP(&yqlib.ConfiguredSecurityPreferences.EnableSystemOps, "enable-system-operator", "", false, "Enable system operator to allow execution of external commands.")
|
rootCmd.PersistentFlags().BoolVarP(&yqlib.ConfiguredSecurityPreferences.EnableSystemOps, "security-enable-system-operator", "", false, "Enable system operator to allow execution of external commands.")
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&yqlib.ConfiguredSecurityPreferences.EnableSystemOps, "enable-system-operator", "", false, "DEPRECATED: use --security-enable-system-operator instead. Enable system operator to allow execution of external commands.")
|
||||||
|
if err = rootCmd.MarkPersistentFlagDeprecated("enable-system-operator", "use --security-enable-system-operator instead."); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
rootCmd.AddCommand(
|
rootCmd.AddCommand(
|
||||||
createEvaluateSequenceCommand(),
|
createEvaluateSequenceCommand(),
|
||||||
|
|||||||
@ -33,6 +33,9 @@ func resolveCommandNode(commandNodes Context) (string, error) {
|
|||||||
if cmdNode.Kind != ScalarNode || cmdNode.Tag == "!!null" {
|
if cmdNode.Kind != ScalarNode || cmdNode.Tag == "!!null" {
|
||||||
return "", fmt.Errorf("system operator: command must be a string scalar")
|
return "", fmt.Errorf("system operator: command must be a string scalar")
|
||||||
}
|
}
|
||||||
|
if cmdNode.Value == "" {
|
||||||
|
return "", fmt.Errorf("system operator: command must be a non-empty string")
|
||||||
|
}
|
||||||
return cmdNode.Value, nil
|
return cmdNode.Value, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,13 +92,11 @@ func systemOperator(d *dataTreeNavigator, context Context, expressionNode *Expre
|
|||||||
}
|
}
|
||||||
|
|
||||||
var stdin bytes.Buffer
|
var stdin bytes.Buffer
|
||||||
if candidate.Tag != "!!null" {
|
encoded, err := encodeToYamlString(candidate)
|
||||||
encoded, err := encodeToYamlString(candidate)
|
if err != nil {
|
||||||
if err != nil {
|
return Context{}, err
|
||||||
return Context{}, err
|
|
||||||
}
|
|
||||||
stdin.WriteString(encoded)
|
|
||||||
}
|
}
|
||||||
|
stdin.WriteString(encoded)
|
||||||
|
|
||||||
// #nosec G204 - intentional: user must explicitly enable this operator
|
// #nosec G204 - intentional: user must explicitly enable this operator
|
||||||
cmd := exec.Command(command, args...)
|
cmd := exec.Command(command, args...)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user