nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: metallb/metallb
Pull request #2052 (2023-08-22 13:51:58)

Fix Gosec error in the configmaptocrs
Fix Gosec error inside the configmaptocrs:
G601 (CWE-118): Implicit memory aliasing in for loop. (Confidence: MEDIUM, Severity: MEDIUM)

This is also a bug fix because it didn't create
the correct echoMode and passiveMode values in the CRD. Updated the golden files.

fedepaol: LGTM. thanks

Patch:
diff --git a/configmaptocrs/main.go b/configmaptocrs/main.go
index b95953ba..f307c316 100644
--- a/configmaptocrs/main.go
+++ b/configmaptocrs/main.go
@@ -229,8 +229,8 @@ func bfdProfileFor(c *configFile) []v1beta1.BFDProfile {
 				TransmitInterval: bfd.TransmitInterval,
 				DetectMultiplier: bfd.DetectMultiplier,
 				EchoInterval:     bfd.EchoInterval,
-				EchoMode:         &bfd.EchoMode,
-				PassiveMode:      &bfd.PassiveMode,
+				EchoMode:         &c.BFDProfiles[i].EchoMode,
+				PassiveMode:      &c.BFDProfiles[i].PassiveMode,
 				MinimumTTL:       bfd.MinimumTTL,
 			},
 		}


Test patch:
diff --git a/configmaptocrs/testdata/configmap-data/config-data-bfdprofile.golden b/configmaptocrs/testdata/configmap-data/config-data-bfdprofile.golden
index d10ead79..7bfcf313 100644
--- a/configmaptocrs/testdata/configmap-data/config-data-bfdprofile.golden
+++ b/configmaptocrs/testdata/configmap-data/config-data-bfdprofile.golden
@@ -8,9 +8,9 @@ metadata:
 spec:
   detectMultiplier: 200
   echoInterval: 62
-  echoMode: true
+  echoMode: false
   minimumTtl: 254
-  passiveMode: true
+  passiveMode: false
   receiveInterval: 280
   transmitInterval: 270
 status: {}
diff --git a/configmaptocrs/testdata/configmap-yaml/config-yaml-bfdprofile.golden b/configmaptocrs/testdata/configmap-yaml/config-yaml-bfdprofile.golden
index d10ead79..7bfcf313 100644
--- a/configmaptocrs/testdata/configmap-yaml/config-yaml-bfdprofile.golden
+++ b/configmaptocrs/testdata/configmap-yaml/config-yaml-bfdprofile.golden
@@ -8,9 +8,9 @@ metadata:
 spec:
   detectMultiplier: 200
   echoInterval: 62
-  echoMode: true
+  echoMode: false
   minimumTtl: 254
-  passiveMode: true
+  passiveMode: false
   receiveInterval: 280
   transmitInterval: 270
 status: {}
Repository: vitessio/vitess
Pull request #8035 (2021-05-04 18:09:20)

[9.0] ddl bypass planner
# Description

* Backports https://github.com/vitessio/vitess/pull/8013 to 9.0.



Patch:
diff --git a/go/vt/vtgate/planbuilder/ddl.go b/go/vt/vtgate/planbuilder/ddl.go
index 77873b3abb..f0627c8723 100644
--- a/go/vt/vtgate/planbuilder/ddl.go
+++ b/go/vt/vtgate/planbuilder/ddl.go
@@ -24,6 +24,10 @@ const (
 // This is why we return a compound primitive (DDL) which contains fully populated primitives (Send & OnlineDDL),
 // and which chooses which of the two to invoke at runtime.
 func buildGeneralDDLPlan(sql string, ddlStatement sqlparser.DDLStatement, vschema ContextVSchema) (engine.Primitive, error) {
+	if vschema.Destination() != nil {
+		return buildByPassDDLPlan(sql, vschema)
+	}
+
 	normalDDLPlan, onlineDDLPlan, err := buildDDLPlans(sql, ddlStatement, vschema)
 	if err != nil {
 		return nil, err
@@ -38,6 +42,18 @@ func buildGeneralDDLPlan(sql string, ddlStatement sqlparser.DDLStatement, vschem
 	}, nil
 }
 
+func buildByPassDDLPlan(sql string, vschema ContextVSchema) (engine.Primitive, error) {
+	keyspace, err := vschema.DefaultKeyspace()
+	if err != nil {
+		return nil, err
+	}
+	return &engine.Send{
+		Keyspace:          keyspace,
+		TargetDestination: vschema.Destination(),
+		Query:             sql,
+	}, nil
+}
+
 func buildDDLPlans(sql string, ddlStatement sqlparser.DDLStatement, vschema ContextVSchema) (*engine.Send, *engine.OnlineDDL, error) {
 	var destination key.Destination
 	var keyspace *vindexes.Keyspace


Test patch:
diff --git a/go/vt/vtgate/planbuilder/testdata/bypass_cases.txt b/go/vt/vtgate/planbuilder/testdata/bypass_cases.txt
index daafda9d36..7bb0fc36af 100644
--- a/go/vt/vtgate/planbuilder/testdata/bypass_cases.txt
+++ b/go/vt/vtgate/planbuilder/testdata/bypass_cases.txt
@@ -156,3 +156,21 @@
     "SingleShardOnly": true
   }
 }
+
+# create table
+"create /* test */ table t1(id bigint, primary key(id)) /* comments */"
+{
+  "QueryType": "DDL",
+  "Original": "create /* test */ table t1(id bigint, primary key(id)) /* comments */",
+  "Instructions": {
+    "OperatorType": "Send",
+    "Keyspace": {
+      "Name": "main",
+      "Sharded": false
+    },
+    "TargetDestination": "Shard(-80)",
+    "IsDML": false,
+    "Query": "create /* test */ table t1(id bigint, primary key(id)) /* comments */",
+    "SingleShardOnly": false
+  }
+}
Repository: kentik/ktranslate
Pull request #125 (2021-09-03 17:52:41)

Allowing override of instrumentationName on a per device basis
set a custom `instrumentation.name` value by setting `instrumentationName` in the device snmp config. 


Patch:
diff --git a/pkg/inputs/snmp/metrics/device_metrics.go b/pkg/inputs/snmp/metrics/device_metrics.go
index df946d5..ae19c54 100644
--- a/pkg/inputs/snmp/metrics/device_metrics.go
+++ b/pkg/inputs/snmp/metrics/device_metrics.go
@@ -51,7 +51,7 @@ func NewDeviceMetrics(gconf *kt.SnmpGlobalConfig, conf *kt.SnmpDeviceConfig, met
 		log:         log,
 		conf:        conf,
 		metrics:     metrics,
-		profileName: profile.GetProfileName(),
+		profileName: profile.GetProfileName(conf.InstrumentationName),
 	}
 }
 
diff --git a/pkg/inputs/snmp/metrics/interface_metrics.go b/pkg/inputs/snmp/metrics/interface_metrics.go
index b331679..0cc94a0 100644
--- a/pkg/inputs/snmp/metrics/interface_metrics.go
+++ b/pkg/inputs/snmp/metrics/interface_metrics.go
@@ -94,7 +94,7 @@ func NewInterfaceMetrics(gconf *kt.SnmpGlobalConfig, conf *kt.SnmpDeviceConfig,
 		nameOidMap:  nameOidMap,
 		oidMibMap:   profileMetrics,
 		intValues:   make(map[string]*counters.CounterSet),
-		profileName: profile.GetProfileName(),
+		profileName: profile.GetProfileName(conf.InstrumentationName),
 	}
 }
 
diff --git a/pkg/inputs/snmp/mibs/profile.go b/pkg/inputs/snmp/mibs/profile.go
index 96c14b4..cd23b5a 100644
--- a/pkg/inputs/snmp/mibs/profile.go
+++ b/pkg/inputs/snmp/mibs/profile.go
@@ -54,7 +54,11 @@ type Profile struct {
 	extended        bool
 }
 
-func (p *Profile) GetProfileName() string {
+func (p *Profile) GetProfileName(override string) string {
+	if override != "" { // This can override what is set as the profile name.
+		return override
+	}
+
 	if p == nil {
 		return "snmp"
 	}
diff --git a/pkg/kt/snmp.go b/pkg/kt/snmp.go
index 13f88f1..a7bf1b8 100644
--- a/pkg/kt/snmp.go
+++ b/pkg/kt/snmp.go
@@ -115,6 +115,7 @@ type SnmpDeviceConfig struct {
 	MatchAttr              map[string]string `yaml:"match_attributes"`
 	MonitorAdminShut       bool              `yaml:"monitor_admin_shut"`
 	NoUseBulkWalkAll       bool              `yaml:"no_use_bulkwalkall"`
+	InstrumentationName    string            `yaml:"instrumentationName"`
 }
 
 type SnmpTrapConfig struct {


Test patch:
diff --git a/pkg/inputs/snmp/mibs/profile_test.go b/pkg/inputs/snmp/mibs/profile_test.go
index daf1cea..851472d 100644
--- a/pkg/inputs/snmp/mibs/profile_test.go
+++ b/pkg/inputs/snmp/mibs/profile_test.go
@@ -73,11 +73,15 @@ func TestProfileName(t *testing.T) {
 		"foo-test": []*Profile{&Profile{From: "foo-test.yml"}},
 		"snmp":     []*Profile{nil, &Profile{}},
 		"noone":    []*Profile{&Profile{From: "noone"}},
+		"override": []*Profile{&Profile{From: "lalalalala"}},
+	}
+	overrides := map[string]string{
+		"override": "override",
 	}
 
 	for expected, profiles := range tests {
 		for _, profile := range profiles {
-			res := profile.GetProfileName()
+			res := profile.GetProfileName(overrides[expected])
 			assert.Equal(t, expected, res)
 		}
 	}
Repository: kentik/ktranslate
Pull request #191 (2021-11-15 23:55:40)

Allow a hextoip conversion
This addresses #189, converting IPs encoded as Hex into a string. 


Patch:
diff --git a/pkg/inputs/snmp/util/util.go b/pkg/inputs/snmp/util/util.go
index 3f566df..3829ecc 100644
--- a/pkg/inputs/snmp/util/util.go
+++ b/pkg/inputs/snmp/util/util.go
@@ -21,6 +21,7 @@ const (
 	CONV_HWADDR   = "hwaddr"
 	CONV_POWERSET = "powerset_status"
 	CONV_HEXTOINT = "hextoint"
+	CONV_HEXTOIP  = "hextoip"
 
 	NRUserTagPrefix = "tags."
 )
@@ -240,6 +241,8 @@ func GetFromConv(pdu gosnmp.SnmpPDU, conv string, log logger.ContextL) (int64, s
 		return 0, net.HardwareAddr(bv).String()
 	case CONV_POWERSET:
 		return vendor.HandlePowersetStatus(bv)
+	case CONV_HEXTOIP:
+		return hexToIP(bv)
 	default:
 		// Otherwise, try out some custom conversions.
 		split := strings.Split(conv, ":")
@@ -280,3 +283,31 @@ func GetFromConv(pdu gosnmp.SnmpPDU, conv string, log logger.ContextL) (int64, s
 
 	return 0, string(bv) // Default down to here.
 }
+
+/**
+Some OID's don't store IP as a string, they store it as a hex value that we are going to want to translate.
+I need to take this:
+.1.3.6.1.4.1.9.9.42.1.2.2.1.2.1 = Hex-String: 0A00640A
+and display it as a string 10.0.100.10
+*/
+func hexToIP(bv []byte) (int64, string) {
+	switch len(bv) {
+	case 8:
+		return 0, fmt.Sprintf("%d.%d.%d.%d",
+			binary.BigEndian.Uint16(bv[0:2]),
+			binary.BigEndian.Uint16(bv[2:4]),
+			binary.BigEndian.Uint16(bv[4:6]),
+			binary.BigEndian.Uint16(bv[6:8]),
+		)
+	case 4:
+		nv := []byte{0x00, bv[0], 0x00, bv[1], 0x00, bv[2], 0x00, bv[3]}
+		return 0, fmt.Sprintf("%d.%d.%d.%d",
+			binary.BigEndian.Uint16(nv[0:2]),
+			binary.BigEndian.Uint16(nv[2:4]),
+			binary.BigEndian.Uint16(nv[4:6]),
+			binary.BigEndian.Uint16(nv[6:8]),
+		)
+	default:
+		return 0, ""
+	}
+}


Test patch:
diff --git a/pkg/inputs/snmp/util/util_test.go b/pkg/inputs/snmp/util/util_test.go
index 80397c1..9fbf8a4 100644
--- a/pkg/inputs/snmp/util/util_test.go
+++ b/pkg/inputs/snmp/util/util_test.go
@@ -142,3 +142,19 @@ func TestHexToInt(t *testing.T) {
 		assert.Equal(expt, str, "%s", in)
 	}
 }
+
+func TestHexToIP(t *testing.T) {
+	assert := assert.New(t)
+	l := lt.NewTestContextL(logger.NilContext, t)
+
+	tests := map[string][]byte{
+		"10.0.100.10": []byte{0x00, 0x0a, 0x00, 0x00, 0x00, 0x64, 0x00, 0x0a},
+		"10.0.100.11": []byte{0x0a, 0x00, 0x64, 0x0b},
+	}
+
+	for expt, in := range tests {
+		pdu := gosnmp.SnmpPDU{Value: in}
+		_, str := GetFromConv(pdu, CONV_HEXTOIP, l)
+		assert.Equal(expt, str, "%s", in)
+	}
+}
Repository: iter8-tools/iter8
Pull request #1287 (2022-06-20 05:31:36)

Change `startingTime` to RFC 3339


Patch:
diff --git a/base/collect_database.go b/base/collect_database.go
index f075bd0f..7fadf6bf 100644
--- a/base/collect_database.go
+++ b/base/collect_database.go
@@ -90,9 +90,6 @@ const (
 	startingTimeStr = "startingTime"
 
 	elapsedTimeSecondsStr = "elapsedTimeSeconds"
-
-	// timeLayout is an example time layout for startingTime
-	timeLayout = "Jan 2, 2006 at 3:04pm (MST)"
 )
 
 // collectDatabaseTask enables load testing of gRPC services.
@@ -124,7 +121,7 @@ func getElapsedTimeSeconds(versionInfo map[string]interface{}, exp *Experiment)
 	startingTime := exp.Result.StartTime.Unix()
 	if versionInfo[startingTimeStr] != nil {
 		// Calling Parse() method with its parameters
-		temp, err := time.Parse(timeLayout, fmt.Sprintf("%v", versionInfo[startingTimeStr]))
+		temp, err := time.Parse(time.RFC3339, fmt.Sprintf("%v", versionInfo[startingTimeStr]))
 
 		if err != nil {
 			return 0, errors.New("cannot parse startingTime")


Test patch:
diff --git a/action/gen_test.go b/action/gen_test.go
index 5afca719..858a49d2 100644
--- a/action/gen_test.go
+++ b/action/gen_test.go
@@ -53,7 +53,7 @@ func TestGenDB(t *testing.T) {
 	gOpts := NewGenOpts()
 	gOpts.ChartsParentDir = base.CompletePath("../", "")
 	gOpts.ChartName = "slo-validation-istio"
-	gOpts.Values = []string{"providerURL=http://prometheus.istio-system:9090/api/v1/query", "destination_workload=httpbin-v2", "destination_workload_namespace=default", `startingTime="Feb 4\, 2014 at 6:05pm (PST)"`, "istio/error-rate=0"}
+	gOpts.Values = []string{"providerURL=http://prometheus.istio-system:9090/api/v1/query", "destination_workload=httpbin-v2", "destination_workload_namespace=default", `startingTime="2020-02-01T09:44:40Z"`, "istio/error-rate=0"}
 
 	err := gOpts.LocalRun()
 	assert.NoError(t, err)
diff --git a/base/collect_database_test.go b/base/collect_database_test.go
index cb57e198..12351927 100644
--- a/base/collect_database_test.go
+++ b/base/collect_database_test.go
@@ -103,7 +103,7 @@ func GoToTempDirectoryAndCopyMetricsFile(t *testing.T, metricsFileName string, t
 // test getElapsedTimeSeconds()
 func TestGetElapsedTimeSeconds(t *testing.T) {
 	versionInfo := map[string]interface{}{
-		"startingTime": "Feb 4, 2014 at 6:05pm (PST)",
+		"startingTime": "2020-02-01T09:44:40Z",
 	}
 
 	exp := &Experiment{
@@ -127,8 +127,8 @@ func TestGetElapsedTimeSeconds(t *testing.T) {
 // test if a user sets elapsedTimeSeconds getElapsedTimeSeconds()
 func TestSetElapsedTimeSecondsError(t *testing.T) {
 	versionInfo := map[string]interface{}{
-		"startingTime":       "Feb 4, 2014 at 6:05pm (PST)",
-		"elapsedTimeSeconds": "Feb 5, 2014 at 6:05pm (PST)",
+		"startingTime":       "2020-02-01T09:44:40Z",
+		"elapsedTimeSeconds": "2020-02-01T09:44:40Z",
 	}
 
 	exp := &Experiment{
Repository: iter8-tools/iter8
Pull request #1317 (2022-08-12 13:21:27)

Dockerfile for dev
Signed-off-by: Michael Kalantar <kalantar@us.ibm.com>

Fixes https://github.com/iter8-tools/iter8/issues/1315

To use, first execute `make dist`. Then build image: `docker build . -f Dockerfile.dev -t TAG`


Patch:
diff --git a/Dockerfile.dev b/Dockerfile.dev
new file mode 100644
index 00000000..23387d89
--- /dev/null
+++ b/Dockerfile.dev
@@ -0,0 +1,27 @@
+# Get Iter8
+FROM golang:1.18-buster as builder
+
+# Install wget
+# N/A
+# Set Iter8 version from build args
+# N/A
+
+# Download iter8 compressed binary
+# use COPY instead of wget
+COPY _dist/iter8-linux-amd64.tar.gz iter8-linux-amd64.tar.gz
+
+# Extract iter8
+RUN tar -xvf iter8-linux-amd64.tar.gz
+
+# Extract iter8
+RUN mv linux-amd64/iter8 /bin/iter8
+
+### Multi-stage Docker build
+### New image below
+
+# Small linux image with iter8 binary
+FROM debian:buster-slim
+WORKDIR /
+COPY --from=builder /bin/iter8 /bin/iter8
+# Install curl
+RUN apt-get update && apt-get install -y curl
diff --git a/cmd/kdelete.go b/cmd/kdelete.go
index de06dc24..e7361917 100644
--- a/cmd/kdelete.go
+++ b/cmd/kdelete.go
@@ -34,7 +34,7 @@ func newKDeleteCmd(kd *driver.KubeDriver, out io.Writer) *cobra.Command {
 	return cmd
 }
 
-// intialize with the k delete cmd
+// initialize with the k delete cmd
 func init() {
 	kCmd.AddCommand(newKDeleteCmd(kd, os.Stdout))
 }
diff --git a/cmd/klog.go b/cmd/klog.go
index 4c38f1f2..f5751d0e 100644
--- a/cmd/klog.go
+++ b/cmd/klog.go
@@ -14,7 +14,7 @@ Fetch logs for a Kubernetes experiment.
 	iter8 k log
 `
 
-// newKLogCmd creates the Kubernetes log commmand
+// newKLogCmd creates the Kubernetes log command
 func newKLogCmd(kd *driver.KubeDriver) *cobra.Command {
 	actor := ia.NewLogOpts(kd)
 


Test patch:
diff --git a/base/readiness_test.go b/base/readiness_test.go
index 49f1812a..51e2e8d5 100644
--- a/base/readiness_test.go
+++ b/base/readiness_test.go
@@ -22,7 +22,7 @@ func TestNoObject(t *testing.T) {
 	os.Chdir(t.TempDir())
 	ns, nm := "default", "test-pod"
 	pod := newPod(ns, nm).withCondition("Ready", "True").build()
-	rTask := newReadinessTask("non-existant-pod").withVersion("v1").withResource("pods").withNamespace(ns).withCondition("Ready").build()
+	rTask := newReadinessTask("non-existent-pod").withVersion("v1").withResource("pods").withNamespace(ns).withCondition("Ready").build()
 	runTaskTest(t, rTask, false, ns, pod)
 }
Repository: iter8-tools/iter8
Pull request #1597 (2023-08-28 13:12:46)

Fix readiness test with namespace


Patch:
diff --git a/.github/workflows/verifyuserexperience.yaml b/.github/workflows/verifyuserexperience.yaml
index 67137ae2..29abc618 100644
--- a/.github/workflows/verifyuserexperience.yaml
+++ b/.github/workflows/verifyuserexperience.yaml
@@ -452,4 +452,4 @@ jobs:
 
     - name: Check GET /httpDashboard
       run: |
-        curl "http://localhost:8080/httpDashboard?namespace=default&experiment=default" -f
+        curl "http://localhost:8080/httpDashboard?namespace=experiments&experiment=default" -f


Test patch:
diff --git a/.github/workflows/testcode.yaml b/.github/workflows/testcode.yaml
index 87eac79a..1371eef5 100644
--- a/.github/workflows/testcode.yaml
+++ b/.github/workflows/testcode.yaml
@@ -13,32 +13,6 @@ on:
     - 'testdata/**'
 
 jobs:
-  unit-test:
-    name: unit-test
-    runs-on: ubuntu-latest
-    steps:
-    - name: Install Go
-      uses: actions/setup-go@v4
-      with:
-        go-version: 1.19
-
-    - name: Check out code into the Go module directory
-      uses: actions/checkout@v3
-
-    - name: Test and compute coverage
-      run: make coverage # includes vet and lint
-
-    - name: Enforce coverage
-      run: |
-        export COVERAGE=$(go tool cover -func coverage.out | grep total | awk '{print substr($3, 1, length($3)-1)}')
-        echo "code coverage is at ${COVERAGE}"
-        if [ 1 -eq "$(echo "${COVERAGE} > 76.0" | bc)" ]; then \
-          echo "all good... coverage is above 76.0%"; 
-        else \
-          echo "not good... coverage is not above 76.0%";
-          exit 1
-        fi
-
   cli-test-http:
     name: CLI test with http task
     runs-on: ubuntu-latest
diff --git a/.github/workflows/unittest.yaml b/.github/workflows/unittest.yaml
new file mode 100644
index 00000000..d028ed1d
--- /dev/null
+++ b/.github/workflows/unittest.yaml
@@ -0,0 +1,37 @@
+name: Unit test
+
+# Runs during pull request
+
+# Always needs to pass in order for PR to be accepted
+
+on:
+  pull_request:
+    branches:
+    - master
+
+jobs:
+  unit-test:
+    name: unit-test
+    runs-on: ubuntu-latest
+    steps:
+    - name: Install Go
+      uses: actions/setup-go@v4
+      with:
+        go-version: 1.19
+
+    - name: Check out code into the Go module directory
+      uses: actions/checkout@v3
+
+    - name: Test and compute coverage
+      run: make coverage # includes vet and lint
+
+    - name: Enforce coverage
+      run: |
+        export COVERAGE=$(go tool cover -func coverage.out | grep total | awk '{print substr($3, 1, length($3)-1)}')
+        echo "code coverage is at ${COVERAGE}"
+        if [ 1 -eq "$(echo "${COVERAGE} > 76.0" | bc)" ]; then \
+          echo "all good... coverage is above 76.0%"; 
+        else \
+          echo "not good... coverage is not above 76.0%";
+          exit 1
+        fi