Skip to content

Commit e9dbb5e

Browse files
authored
security: run pre-commit autoupdate --freeze; Pin to sha all hooks (#13855)
1 parent 719dbe9 commit e9dbb5e

9 files changed

Lines changed: 50 additions & 51 deletions

File tree

.pre-commit-config.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ repos:
2626
- id: identity
2727
- id: check-hooks-apply
2828
- repo: https://github.com/thlorenz/doctoc.git
29-
rev: v2.3.0
29+
rev: 59dcae910a6ad4bbe8711275b854e3cd5c30f08b # frozen: v2.5.0
3030
hooks:
3131
- id: doctoc
3232
name: Add TOC for Markdown files
@@ -43,20 +43,20 @@ repos:
4343
files: (?i)\.zip$
4444
exclude: ^core/src/test/resources/vhds/test\.vhd\.zip$
4545
- repo: https://github.com/oxipng/oxipng
46-
rev: v10.1.0
46+
rev: 340cd9878d8d8289f09fa101b48a8f5f0b7783f4 # frozen: v10.2.0
4747
hooks:
4848
- id: oxipng
4949
name: run oxipng
5050
description: optimize PNG images with lossless compression
5151
args: ['-o', '4', '--strip', 'safe', '--alpha']
5252
- repo: https://github.com/gitleaks/gitleaks
53-
rev: v8.30.0
53+
rev: 83d9cd684c87d95d656c1458ef04895a7f1cbd8e # frozen: v8.30.1
5454
hooks:
5555
- id: gitleaks
5656
name: run gitleaks
5757
description: detect hardcoded secrets
5858
- repo: https://github.com/Lucas-C/pre-commit-hooks
59-
rev: v1.5.6
59+
rev: ad1b27d73581aa16cca06fc4a0761fc563ffe8e8 # frozen: v1.5.6
6060
hooks:
6161
- id: chmod
6262
name: set file permissions
@@ -143,7 +143,7 @@ repos:
143143
- --fuzzy-match-generates-todo
144144
exclude: ^\.github/workflows/.*\.lock\.yml$
145145
- repo: https://github.com/pre-commit/pre-commit-hooks
146-
rev: v6.0.0
146+
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
147147
hooks:
148148
#- id: check-added-large-files
149149
- id: check-case-conflict
@@ -187,18 +187,18 @@ repos:
187187
args: [--markdown-linebreak-ext=md]
188188
exclude: ^services/console-proxy/rdpconsole/src/test/doc/freerdp-debug-log\.txt$
189189
- repo: https://github.com/codespell-project/codespell
190-
rev: v2.4.2
190+
rev: 57b21406f092110c18776e39b0bda50d37c945c8 # frozen: v2.4.3
191191
hooks:
192192
- id: codespell
193193
name: run codespell
194194
description: Check spelling with codespell
195195
- repo: https://github.com/pycqa/flake8
196-
rev: 7.3.0
196+
rev: c48217e1fc006c2dddd14df54e83b67da15de5cd # frozen: 7.3.0
197197
hooks:
198-
- id: flake8
199-
args: [--config, .github/linters/.flake8]
198+
- id: flake8
199+
args: [--config, .github/linters/.flake8]
200200
- repo: https://github.com/igorshubovych/markdownlint-cli
201-
rev: v0.48.0
201+
rev: 5b5dddc4fb0f83c3ea1fc5616fa63e115dce83e0 # frozen: v0.49.1
202202
hooks:
203203
- id: markdownlint
204204
name: run markdownlint
@@ -207,7 +207,7 @@ repos:
207207
types: [markdown]
208208
files: \.md$
209209
- repo: https://github.com/adrienverge/yamllint
210-
rev: v1.38.0
210+
rev: cba56bcde1fdd01c1deb3f945e69764c291a6530 # frozen: v1.38.0
211211
hooks:
212212
- id: yamllint
213213
name: run yamllint

plugins/hypervisors/ovm/src/main/scripts/vm/hypervisor/ovm/OvmOCFS2Module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def _isClusterOnline(self, cluster):
5454
cmds = ['service o2cb status', cluster]
5555
res = doCmd(cmds)
5656
for line in res.split('\n'):
57-
if not 'Checking O2CB cluster' in line: continue
58-
return not 'Offline' in line
57+
if 'Checking O2CB cluster' not in line: continue
58+
return 'Offline' not in line
5959

6060
def _load(self):
6161
cmd = ['service o2cb load']

scripts/vm/hypervisor/xenserver/cloudstack_pluginlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ def create_tunnel(bridge, remote_ip, gre_key, src_host, dst_host, network_uuid):
409409
key_validation = do_cmd(verify_interface_key)
410410
ip_validation = do_cmd(verify_interface_ip)
411411

412-
if not gre_key in key_validation or not remote_ip in ip_validation:
412+
if gre_key not in key_validation or remote_ip not in ip_validation:
413413
logging.debug("WARNING: Unexpected output while verifying " +
414414
"interface %s on bridge %s" % (name, bridge))
415415
return "FAILURE:VERIFY_INTERFACE_FAILED"

scripts/vm/hypervisor/xenserver/vmops

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ def cleanup_rules(session, args):
11801180

11811181
chainscmd = "iptables-save | grep '^:' | awk '{print $1}' | cut -d':' -f2 | sed 's/-def//'| sed 's/-eg//' | sort|uniq"
11821182
chains = util.pread2(['/bin/bash', '-c', chainscmd]).split('\n')
1183-
vmchains = [ch for ch in chains if 1 in [ ch.startswith(c) for c in ['r-', 'i-', 's-', 'v-', 'l-']]]
1183+
vmchains = [ch for ch in chains if 1 in [ ch.startswith(c) for c in ['r-', 'i-', 's-', 'v-', 'l-']]]
11841184
util.SMlog('cleanup_rules: vmchains= %s' %vmchains)
11851185
util.SMlog('cleanup_rules: found %s iptables chains for vms on this host %s' % (len(vmchains), hostname[0]))
11861186
cleaned = 0
@@ -1192,14 +1192,14 @@ def cleanup_rules(session, args):
11921192
#after trimming the vm names which more than 29 chars, resident vm name and iptables chain name is substring of
11931193
#of resident vm.
11941194
for rvm in resident_vms:
1195-
if vmname in rvm:
1195+
if vmname in rvm:
11961196
vmpresent = True
11971197
break
11981198

11991199
if vmpresent is False:
12001200
vmname = chain + "-untagged"
12011201
for rvm in resident_vms:
1202-
if vmname in rvm:
1202+
if vmname in rvm:
12031203
vmpresent = True
12041204
break
12051205
#vm chain is present but vm is not running on the host. So remove the rules
@@ -1491,11 +1491,11 @@ def network_rules(session, args):
14911491
egressrules = 0
14921492
for line in lines:
14931493
logging.debug("Processing rule [%s]." % line)
1494-
1494+
14951495
#Example of rule: [I:tcp;12;34;1.2.3.4/24,NEXT] -> tokens: ['I:tcp', '12', '34', '1.2.3.4/24,NEXT'].
14961496
tokens = line.split(';')
14971497
logging.debug("Tokens %s." % tokens)
1498-
1498+
14991499
tokens_size = len(tokens)
15001500

15011501
expected_tokens_size = 4
@@ -1530,7 +1530,7 @@ def network_rules(session, args):
15301530
i = cidrs.index('0.0.0.0/0')
15311531
del cidrs[i]
15321532
allow_any = True
1533-
1533+
15341534
port_range = start + ":" + end
15351535
logging.debug("port range [%s]" % port_range)
15361536

scripts/vm/hypervisor/xenserver/vmopsSnapshot

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
# to you under the Apache License, Version 2.0 (the
77
# "License"); you may not use this file except in compliance
88
# with the License. You may obtain a copy of the License at
9-
#
9+
#
1010
# http://www.apache.org/licenses/LICENSE-2.0
11-
#
11+
#
1212
# Unless required by applicable law or agreed to in writing,
1313
# software distributed under the License is distributed on an
1414
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -18,7 +18,7 @@
1818

1919
# Version @VERSION@
2020
#
21-
# A plugin for executing script needed by vmops cloud
21+
# A plugin for executing script needed by vmops cloud
2222

2323
import os, sys, time
2424
import XenAPIPlugin
@@ -91,7 +91,7 @@ def create_secondary_storage_folder(session, args):
9191
umount(local_mount_path)
9292
# Remove the local folder
9393
os.system("rmdir " + local_mount_path)
94-
94+
9595
return "1"
9696

9797
@echo
@@ -127,15 +127,15 @@ def delete_secondary_storage_folder(session, args):
127127
umount(local_mount_path)
128128
# Remove the local folder
129129
os.system("rmdir " + local_mount_path)
130-
130+
131131
return "1"
132-
132+
133133
@echo
134134
def post_create_private_template(session, args):
135135
local_mount_path = None
136136
try:
137137
try:
138-
# get local template folder
138+
# get local template folder
139139
templatePath = args["templatePath"]
140140
local_mount_path = os.path.join(CLOUD_DIR, util.gen_uuid())
141141
nfsVersion = args["nfsVersion"]
@@ -148,7 +148,7 @@ def post_create_private_template(session, args):
148148
file_size = args["size"]
149149
virtual_size = args["virtualSize"]
150150
template_id = args["templateId"]
151-
151+
152152
# Create the template.properties file
153153
template_properties_install_path = local_mount_path + "/template.properties"
154154
f = open(template_properties_install_path, "w")
@@ -167,7 +167,7 @@ def post_create_private_template(session, args):
167167
f.write("size=" + str(file_size) + "\n")
168168
f.close()
169169
logging.debug("Created template.properties file")
170-
170+
171171
# Set permissions
172172
permissions = stat.S_IREAD | stat.S_IWRITE | stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH | stat.S_IWOTH
173173
os.chmod(template_properties_install_path, permissions)
@@ -184,16 +184,16 @@ def post_create_private_template(session, args):
184184
umount(local_mount_path)
185185
# Remove the local folder
186186
os.system("rmdir " + local_mount_path)
187-
return "1"
188-
187+
return "1"
188+
189189
def isfile(path, isISCSI):
190190
errMsg = ''
191191
exists = True
192192
if isISCSI:
193193
exists = checkVolumeAvailability(path)
194194
else:
195195
exists = os.path.isfile(path)
196-
196+
197197
if not exists:
198198
errMsg = "File " + path + " does not exist."
199199
logging.debug(errMsg)
@@ -241,7 +241,7 @@ def scanParent(path):
241241
try:
242242
lvName = os.path.basename(path)
243243
dirname = os.path.dirname(path)
244-
vgName = os.path.basename(dirname)
244+
vgName = os.path.basename(dirname)
245245
vhdInfo = vhdutil.getVHDInfoLVM(lvName, lvhdutil.extractUuid, vgName)
246246
parentUUID = vhdInfo.parentUuid
247247
except:
@@ -273,7 +273,7 @@ def getParentOfSnapshot(snapshotUuid, primarySRPath, isISCSI):
273273
baseCopyUuid = scanParent(snapshotPath)
274274
else:
275275
baseCopyUuid = getParent(snapshotPath, isISCSI)
276-
276+
277277
logging.debug("Base copy of snapshotUuid: " + snapshotUuid + " is " + baseCopyUuid)
278278
return baseCopyUuid
279279

@@ -282,7 +282,7 @@ def setParent(parent, child):
282282
cmd = [VHDUTIL, "modify", "-p", parent, "-n", child]
283283
txt = util.pread2(cmd)
284284
except:
285-
errMsg = "Unexpected error while trying to set parent of " + child + " to " + parent
285+
errMsg = "Unexpected error while trying to set parent of " + child + " to " + parent
286286
logging.debug(errMsg)
287287
raise xs_errors.XenError(errMsg)
288288
logging.debug("Successfully set parent of " + child + " to " + parent)
@@ -315,32 +315,32 @@ def mount(remoteDir, localDir, nfsVersion=None):
315315
options = "soft,tcp,timeo=133,retrans=1"
316316
if nfsVersion:
317317
options += ",vers=" + nfsVersion
318-
try:
318+
try:
319319
cmd = ['mount', '-o', options, remoteDir, localDir]
320320
txt = util.pread2(cmd)
321321
except:
322322
txt = ''
323-
errMsg = "Unexpected error while trying to mount " + remoteDir + " to " + localDir
323+
errMsg = "Unexpected error while trying to mount " + remoteDir + " to " + localDir
324324
logging.debug(errMsg)
325325
raise xs_errors.XenError(errMsg)
326326
logging.debug("Successfully mounted " + remoteDir + " to " + localDir)
327327

328328
return
329329

330330
def umount(localDir):
331-
try:
331+
try:
332332
cmd = ['umount', localDir]
333333
util.pread2(cmd)
334334
except CommandException:
335-
errMsg = "CommandException raised while trying to umount " + localDir
335+
errMsg = "CommandException raised while trying to umount " + localDir
336336
logging.debug(errMsg)
337337
raise xs_errors.XenError(errMsg)
338338

339339
logging.debug("Successfully unmounted " + localDir)
340340
return
341341

342342
def mountSnapshotsDir(secondaryStorageMountPath, localMountPointPath, path):
343-
# The aim is to mount secondaryStorageMountPath on
343+
# The aim is to mount secondaryStorageMountPath on
344344
# And create <accountId>/<instanceId> dir on it, if it doesn't exist already.
345345
# Assuming that secondaryStorageMountPath exists remotely
346346

@@ -410,7 +410,7 @@ def getIsTrueString(stringValue):
410410
booleanValue = False
411411
if (stringValue and stringValue == 'true'):
412412
booleanValue = True
413-
return booleanValue
413+
return booleanValue
414414

415415
def makeUnavailable(uuid, primarySRPath, isISCSI):
416416
if not isISCSI:
@@ -433,7 +433,7 @@ def manageAvailability(path, value):
433433
logging.debug(errMsg)
434434
if value == "-ay":
435435
# Raise an error only if we are trying to make it available.
436-
# Just warn if we are trying to make it unavailable after the
436+
# Just warn if we are trying to make it unavailable after the
437437
# snapshot operation is done.
438438
raise xs_errors.XenError(errMsg)
439439
return
@@ -450,7 +450,7 @@ def checkVolumeAvailability(path):
450450
errMsg = "Could not determine status of ISCSI path: " + path
451451
logging.debug(errMsg)
452452
raise xs_errors.XenError(errMsg)
453-
453+
454454
success = False
455455
i = 0
456456
while i < 6:
@@ -482,20 +482,20 @@ def isVolumeAvailable(path):
482482
logging.debug(errMsg)
483483
raise xs_errors.XenError(errMsg)
484484

485-
return (status == "1")
485+
return (status == "1")
486486

487487
def getVhdParent(session, args):
488488
logging.debug("getParent with " + str(args))
489489
primaryStorageSRUuid = args['primaryStorageSRUuid']
490490
snapshotUuid = args['snapshotUuid']
491-
isISCSI = getIsTrueString(args['isISCSI'])
491+
isISCSI = getIsTrueString(args['isISCSI'])
492492

493493
primarySRPath = getPrimarySRPath(primaryStorageSRUuid, isISCSI)
494494
logging.debug("primarySRPath: " + primarySRPath)
495495

496496
baseCopyUuid = getParentOfSnapshot(snapshotUuid, primarySRPath, isISCSI)
497497

498-
return baseCopyUuid
498+
return baseCopyUuid
499499

500500
def getSnapshotSize(session, args):
501501
primaryStorageSRUuid = args['primaryStorageSRUuid']
@@ -545,15 +545,15 @@ def backupSnapshot(session, args):
545545
isfile(prevBackupFile, False)
546546

547547
# copy baseCopyPath to backupsDir with new uuid
548-
backupVHD = getBackupVHD(backupUuid)
548+
backupVHD = getBackupVHD(backupUuid)
549549
backupFile = os.path.join(backupsDir, backupVHD)
550550
logging.debug("Back up " + baseCopyUuid + " to Secondary Storage as " + backupUuid)
551551
copyfile(baseCopyPath, backupFile, isISCSI)
552552
vhdutil.setHidden(backupFile, False)
553553

554554
# Because the primary storage is always scanned, the parent of this base copy is always the first base copy.
555555
# We don't want that, we want a chain of VHDs each of which is a delta from the previous.
556-
# So set the parent of the current baseCopyVHD to prevBackupVHD
556+
# So set the parent of the current baseCopyVHD to prevBackupVHD
557557
if prevBackupUuid:
558558
# If there was a previous snapshot
559559
setParent(prevBackupFile, backupFile)
@@ -581,7 +581,7 @@ def deleteSnapshotBackup(session, args):
581581
logging.debug("backupVHD " + backupVHD + "does not exist. Not trying to delete it")
582582
return "1"
583583
logging.debug("backupVHD " + backupVHD + " exists.")
584-
584+
585585
# Just delete the backupVHD
586586
try:
587587
os.remove(backupVHD)
@@ -591,7 +591,7 @@ def deleteSnapshotBackup(session, args):
591591
raise xs_errors.XenError(errMsg)
592592

593593
return "1"
594-
594+
595595
@echo
596596
def revert_memory_snapshot(session, args):
597597
logging.debug("Calling revert_memory_snapshot with " + str(args))
@@ -620,4 +620,3 @@ def revert_memory_snapshot(session, args):
620620

621621
if __name__ == "__main__":
622622
XenAPIPlugin.dispatch({"getVhdParent":getVhdParent, "create_secondary_storage_folder":create_secondary_storage_folder, "delete_secondary_storage_folder":delete_secondary_storage_folder, "post_create_private_template":post_create_private_template, "backupSnapshot": backupSnapshot, "deleteSnapshotBackup": deleteSnapshotBackup, "unmountSnapshotsDir": unmountSnapshotsDir, "revert_memory_snapshot":revert_memory_snapshot, "getSnapshotSize":getSnapshotSize})
623-

systemvm/agent/images/left.png

-6 Bytes
Loading

systemvm/agent/images/right.png

-2 Bytes
Loading

systemvm/agent/images/right2.png

-10 Bytes
Loading

systemvm/agent/images/winlog.png

-46 Bytes
Loading

0 commit comments

Comments
 (0)