Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions .github/workflows/semantic.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

default_install_hook_types:
- pre-commit
- commit-msg

default_language_version:
python: python3.11

Expand All @@ -10,3 +14,19 @@ repos:
hooks:
- id: zizmor
args: ["--no-online-audits"]

# validate the commit message format locally (the same convention the
# .github/workflows/semantic.yml check enforces on the PR)
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v4.5.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args: ["--verbose"]

# static security analysis
- repo: https://github.com/PyCQA/bandit
rev: "1.9.4"
hooks:
- id: bandit
args: ["-q", "-c", "pyproject.toml"]
2 changes: 1 addition & 1 deletion Pilot/pilotCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ def __startJobAgent(self):
if self.pp.executeCmd:
# Execute user command
self.log.info("Executing user defined command: %s" % self.pp.executeCmd)
self.exitWithError(int(os.system("source diracos/diracosrc; %s" % self.pp.executeCmd) / 256))
self.exitWithError(int(os.system("source diracos/diracosrc; %s" % self.pp.executeCmd) / 256)) # nosec B605

self.log.info("Starting JobAgent")
os.environ["PYTHONUNBUFFERED"] = "yes"
Expand Down
12 changes: 6 additions & 6 deletions Pilot/pilotTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def retrieveUrlTimeout(url, fileName, log, timeout=0):
# set timeout alarm
signal.alarm(timeout + 5)
try:
remoteFD = urlopen(url)
remoteFD = urlopen(url) # nosec B310
expectedBytes = 0
# Sometimes repositories do not return Content-Length parameter
try:
Expand Down Expand Up @@ -421,7 +421,7 @@ def getCommand(params, commandName):
try:
commandModule = import_module(module)
commandObject = getattr(commandModule, commandName)
except Exception:
except Exception: # nosec B110
pass
if commandObject:
return commandObject(params), module
Expand Down Expand Up @@ -695,7 +695,7 @@ def sendMessage(url, pilotUUID, wnVO, method, rawMessage):

data = urlencode(raw_data).encode("utf-8") # encode to bytes

res = urlopen(url, data, context=context)
res = urlopen(url, data, context=context) # nosec B310
res.close()


Expand Down Expand Up @@ -747,7 +747,7 @@ def executeAndGetOutput(self, cmd, environDict=None):
self.log.info("Executing command %s" % cmd)
_p = subprocess.Popen(
cmd,
shell=True,
shell=True, # nosec B602
env=environDict,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
Expand Down Expand Up @@ -823,7 +823,7 @@ def forkAndExecute(self, cmd, logFile, environDict=None):
try:
_p = subprocess.Popen(
"%s" % cmd,
shell=True,
shell=True, # nosec B602
env=environDict,
close_fds=False,
stdout=fpLogFile,
Expand Down Expand Up @@ -940,7 +940,7 @@ def __init__(self):
# Set number of allocatable processors from MJF if available
try:
self.pilotProcessors = int(
urlopen(os.path.join(os.environ["JOBFEATURES"], "allocated_cpu")).read()
urlopen(os.path.join(os.environ["JOBFEATURES"], "allocated_cpu")).read() # nosec B310
)
except Exception:
self.pilotProcessors = 1
Expand Down
4 changes: 2 additions & 2 deletions Pilot/proxyTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

def parseASN1(data):
cmd = ["openssl", "asn1parse", "-inform", "der"]
proc = Popen(cmd, stdin=PIPE, stdout=PIPE)
proc = Popen(cmd, stdin=PIPE, stdout=PIPE) # nosec B603
out, _ = proc.communicate(data)
if proc.returncode != 0:
raise Exception("Error when invoking openssl asn1parse")
Expand Down Expand Up @@ -41,7 +41,7 @@ def getVO(proxy_data):

chain = re.findall(br"-----BEGIN CERTIFICATE-----\n.+?\n-----END CERTIFICATE-----", proxy_data, flags=re.DOTALL)
for cert in chain:
proc = Popen(["openssl", "x509", "-outform", "der"], stdin=PIPE, stdout=PIPE)
proc = Popen(["openssl", "x509", "-outform", "der"], stdin=PIPE, stdout=PIPE) # nosec B603, B607
out, _ = proc.communicate(cert)
if proc.returncode != 0:
raise Exception("Error when invoking openssl X509")
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ target-version = ['py39','py310']
[tool.ruff]
select = ["E", "F", "B", "I", "PLE"]
ignore = ["E501"]

[tool.bandit]
exclude_dirs = [".github", "docs", "test", "tests"]
skips = [
"B404", # import_subprocess: the pilot starts processes by design
]