Skip to content

Commit

Permalink
Merge pull request #68 from suecodelabs/feature/restler-opt-out
Browse files Browse the repository at this point in the history
Support opt out for microsoft RESTler telemetry
  • Loading branch information
pcktdmp authored Apr 28, 2022
2 parents 277e0e2 + 7b0a58f commit 46bd728
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ make kind-init
#### Rancher Desktop

```sh
# don't forget to commit your changes locally before deploying to Kind.
# don't forget to commit your changes locally before deploying to Rancher Desktop.
make rancher-init
```

Expand Down
4 changes: 2 additions & 2 deletions charts/cnfuzz/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.2-alpha
version: 0.0.3-alpha

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v0.0.2-alpha"
appVersion: "v0.0.3-alpha"

dependencies:
- name: redis
Expand Down
2 changes: 2 additions & 0 deletions charts/cnfuzz/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ spec:
- "{{ $.Values.scheduler.redisConfig.hostname | default (printf "%s-redis-master" .Release.Name ) }}"
- "--redis-port"
- "{{ $.Values.scheduler.redisConfig.port }}"
- "--restler-telemetry-opt-out"
- "{{ $.Values.scheduler.restlerConfig.restlerTelemetryOptOut }}"
{{- if $.Values.minio.enabled }}
- "--s3-endpoint"
- "http://{{ $.Release.Name }}-minio:9000"
Expand Down
1 change: 1 addition & 0 deletions charts/cnfuzz/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ scheduler:
cpuLimit: 1000 #m
memoryRequest: 1024 #Mi
cpuRequest: 1000 #m
restlerTelemetryOptOut: false
onlyMarked: True
timeBudget: "1" # hour(s)
userName: fuzz-client
Expand Down
18 changes: 11 additions & 7 deletions src/cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ const (
HomeNamespaceFlag = "home-ns" // Namespace to start containers in (jobs etc.)

// fuzzing related flags
RestlerInitImageFlag = "restler-init-img"
RestlerImageFlag = "restler-img"
RestlerTimeBudget = "restler-time-budget"
RestlerCpuLimit = "restler-cpu-limit"
RestlerMemoryLimit = "restler-memory-limit"
RestlerCpuRequest = "restler-cpu-request"
RestlerMemoryRequest = "restler-memory-request"
RestlerInitImageFlag = "restler-init-img"
RestlerImageFlag = "restler-img"
RestlerTelemetryOptOut = "restler-telemetry-opt-out"
RestlerTimeBudget = "restler-time-budget"
RestlerCpuLimit = "restler-cpu-limit"
RestlerMemoryLimit = "restler-memory-limit"
RestlerCpuRequest = "restler-cpu-request"
RestlerMemoryRequest = "restler-memory-request"

// caching related flags
CacheSolution = "cache"
Expand Down Expand Up @@ -72,6 +73,9 @@ func SetupFlags(rootCmd *cobra.Command) {
rootCmd.Flags().StringP(RestlerInitImageFlag, "", "curlimages/curl:7.81.0", "Init Image for preparing RESTler runtime")
_ = viper.BindPFlag(RestlerInitImageFlag, rootCmd.Flags().Lookup(RestlerInitImageFlag))

rootCmd.Flags().StringP(RestlerTelemetryOptOut, "", "", "Opt out for RESTler telemetry collection.")
_ = viper.BindPFlag(RestlerTelemetryOptOut, rootCmd.Flags().Lookup(RestlerTelemetryOptOut))

rootCmd.Flags().StringP(RestlerImageFlag, "", "mcr.microsoft.com/restlerfuzzer/restler:v7.4.0", "RESTler image to use (https://hub.docker.com/_/microsoft-restlerfuzzer-restler)")
_ = viper.BindPFlag(RestlerImageFlag, rootCmd.Flags().Lookup(RestlerImageFlag))

Expand Down
27 changes: 14 additions & 13 deletions src/config/fuzzer_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,20 @@ import (

// FuzzerConfig config that is used to configure the RESTler fuzzer
type FuzzerConfig struct {
JobName string
InitJobName string
Namespace string
Image string
InitImage string
TimeBudget string
CpuLimit int64
MemoryLimit int64
CpuRequest int64
MemoryRequest int64
DiscoveryDocLocation string
Target FuzzerTarget
S3Config S3Config
JobName string
InitJobName string
Namespace string
Image string
InitImage string
TimeBudget string
RestlerTelemetryOptOut string
CpuLimit int64
MemoryLimit int64
CpuRequest int64
MemoryRequest int64
DiscoveryDocLocation string
Target FuzzerTarget
S3Config S3Config
}

// FuzzerTarget configuration for the fuzzing target
Expand Down
6 changes: 6 additions & 0 deletions src/kubernetes/job/restler.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ func createRestlerJob(cnf *config.FuzzerConfig, tokenSource auth.ITokenSource) *
Image: cnf.Image,
Command: []string{"/bin/sh", "-c"},
Args: []string{fullCommand},
Env: []v1.EnvVar{
{
Name: "RESTLER_TELEMETRY_OPTOUT",
Value: cnf.RestlerTelemetryOptOut,
},
},
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{
// CPU, in cores. (500m = .5 cores)
Expand Down

0 comments on commit 46bd728

Please sign in to comment.