feat: avoid safe options to be serialized into the measurement (#859)
Skip options that begin with the `Safe` prefix from appearing in the serialization of a Measurement that will be submitted to the OONI backend. Fixes https://github.com/ooni/probe/issues/2214
This commit is contained in:
parent
2083edb258
commit
d50a39ae92
3 changed files with 57 additions and 2 deletions
|
|
@ -8,6 +8,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine"
|
||||
|
|
@ -183,9 +184,16 @@ func (ed *Experiment) newInputLoader(inputPolicy model.InputPolicy) inputLoader
|
|||
}
|
||||
|
||||
// experimentOptionsToStringList convers the options to []string, which is
|
||||
// the format with which we include them into a OONI Measurement
|
||||
// the format with which we include them into a OONI Measurement. The resulting
|
||||
// []string will skip any option that is named with a `Safe` prefix (case
|
||||
// sensitive).
|
||||
func experimentOptionsToStringList(options map[string]any) (out []string) {
|
||||
// the prefix to skip inclusion in the string list
|
||||
safeOptionPrefix := "Safe"
|
||||
for key, value := range options {
|
||||
if strings.HasPrefix(key, safeOptionPrefix) {
|
||||
continue
|
||||
}
|
||||
out = append(out, fmt.Sprintf("%s=%v", key, value))
|
||||
}
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in a new issue