Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 30d34d0

Browse files
committed
Reduce false positives with verify-flag-underscore.sh by updating regex
Check to make sure there is not an alphanumeric character immeditely before or after the 'flag'. It there is an alphanumeric character then this is obviously not actually the flag we care about. For example if the project declares a flag "valid-name" but the regex finds something like "invalid_name" we should not match. Clearly this "invalid_name" is not actually a wrong usage of the "valid-name" flag.
1 parent ea59172 commit 30d34d0

File tree

6 files changed

+13
-191
lines changed

6 files changed

+13
-191
lines changed

cmd/kube-proxy/app/server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (s *ProxyServer) AddFlags(fs *pflag.FlagSet) {
8181
fs.StringVar(&s.Master, "master", s.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig)")
8282
fs.IntVar(&s.HealthzPort, "healthz-port", s.HealthzPort, "The port to bind the health check server. Use 0 to disable.")
8383
fs.IPVar(&s.HealthzBindAddress, "healthz-bind-address", s.HealthzBindAddress, "The IP address for the health check server to serve on, defaulting to 127.0.0.1 (set to 0.0.0.0 for all interfaces)")
84-
fs.IntVar(&s.OOMScoreAdj, "oom-score-adj", s.OOMScoreAdj, "The oom_score_adj value for kube-proxy process. Values must be within the range [-1000, 1000]")
84+
fs.IntVar(&s.OOMScoreAdj, "oom-score-adj", s.OOMScoreAdj, "The oom-score-adj value for kube-proxy process. Values must be within the range [-1000, 1000]")
8585
fs.StringVar(&s.ResourceContainer, "resource-container", s.ResourceContainer, "Absolute name of the resource-only container to create and run the Kube-proxy in (Default: /kube-proxy).")
8686
fs.StringVar(&s.Kubeconfig, "kubeconfig", s.Kubeconfig, "Path to kubeconfig file with authorization information (the master location is set by the master flag).")
8787
fs.Var(&s.PortRange, "proxy-port-range", "Range of host ports (beginPort-endPort, inclusive) that may be consumed in order to proxy service traffic. If unspecified (0-0) then ports will be randomly chosen.")

contrib/mesos/docs/ha.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
The implementation of the scheduler HA feature includes:
66

77
- Checkpointing by default (`--checkpoint`)
8-
- Large failover-timeout by default (`--failover_timeout`)
8+
- Large failover-timeout by default (`--failover-timeout`)
99
- Hot-failover w/ multiple scheduler instances (`--ha`)
1010
- Best effort task reconciliation on failover
1111

docs/admin/kube-proxy.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ with the apiserver API to configure the proxy.
5656
-h, --help=false: help for kube-proxy
5757
--kubeconfig="": Path to kubeconfig file with authorization information (the master location is set by the master flag).
5858
--master="": The address of the Kubernetes API server (overrides any value in kubeconfig)
59-
--oom-score-adj=0: The oom_score_adj value for kube-proxy process. Values must be within the range [-1000, 1000]
59+
--oom-score-adj=0: The oom-score-adj value for kube-proxy process. Values must be within the range [-1000, 1000]
6060
--proxy-port-range=: Range of host ports (beginPort-endPort, inclusive) that may be consumed in order to proxy service traffic. If unspecified (0-0) then ports will be randomly chosen.
6161
--resource-container="": Absolute name of the resource-only container to create and run the Kube-proxy in (Default: /kube-proxy).
6262
```

docs/admin/kubelet.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ HTTP server: The kubelet can also listen for HTTP and respond to a simple API
9898
--minimum-container-ttl-duration=0: Minimum age for a finished container before it is garbage collected. Examples: '300ms', '10s' or '2h45m'
9999
--network-plugin="": <Warning: Alpha feature> The name of the network plugin to be invoked for various events in kubelet/pod lifecycle
100100
--node-status-update-frequency=0: Specifies how often kubelet posts node status to master. Note: be cautious when changing the constant, it must work with nodeMonitorGracePeriod in nodecontroller. Default: 10s
101-
--oom-score-adj=0: The oom_score_adj value for kubelet process. Values must be within the range [-1000, 1000]
101+
--oom-score-adj=0: The oom-score-adj value for kubelet process. Values must be within the range [-1000, 1000]
102102
--pod-cidr="": The CIDR to use for pod IP addresses, only used in standalone mode. In cluster mode, this is obtained from the master.
103103
--pod-infra-container-image="": The image whose network/ipc namespaces containers in each pod will use.
104104
--port=0: The port for the Kubelet to serve on. Note that "kubectl logs" will not work if you set this flag.
105105
--read-only-port=0: The read-only port for the Kubelet to serve on (set to 0 to disable)
106106
--really-crash-for-testing=false: If true, when panics occur crash. Intended for testing.
107107
--register-node=false: Register the node with the apiserver (defaults to true if --api-server is set)
108-
--registry-burst=0: Maximum size of a bursty pulls, temporarily allows pulls to burst to this number, while still not exceeding registry_qps. Only used if --registry-qps > 0
108+
--registry-burst=0: Maximum size of a bursty pulls, temporarily allows pulls to burst to this number, while still not exceeding registry-qps. Only used if --registry-qps > 0
109109
--registry-qps=0: If > 0, limit registry pull QPS to this value. If 0, unlimited. [default=0.0]
110110
--resource-container="": Absolute name of the resource-only container to create and run the Kubelet in (Default: /kubelet).
111111
--root-dir="": Directory path for managing kubelet files (volume mounts,etc).

hack/verify-flags-underscore.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,10 @@ def normalize_files(rootdir, files):
9696
return newfiles
9797

9898
def line_has_bad_flag(line, flagre):
99-
m = flagre.search(line)
100-
if not m:
101-
return False
102-
if "_" in m.group(0):
103-
return True
99+
results = flagre.findall(line)
100+
for result in results:
101+
if "_" in result:
102+
return True
104103
return False
105104

106105
# The list of files might not be the whole repo. If someone only changed a
@@ -155,7 +154,7 @@ def flags_to_re(flags):
155154
for flag in flags:
156155
# turn all flag names into regexs which will find both types
157156
newre = dashRE.sub('[-_]', flag)
158-
flagREs.append(newre)
157+
flagREs.append("[^\w]" + newre + "[^\w]")
159158
# turn that list of regex strings into a single large RE
160159
flagRE = "|".join(flagREs)
161160
flagRE = re.compile(flagRE)

0 commit comments

Comments
 (0)