Skip to content

Commit 1aa04ab

Browse files
committed
fix: address CodeQL source findings
1 parent cd702cc commit 1aa04ab

9 files changed

Lines changed: 17 additions & 20 deletions

File tree

dist/common/scripts/scylla-housekeeping

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def version_compare(a, b):
9999
def create_uuid_file(fl):
100100
with open(args.uuid_file, 'w') as myfile:
101101
myfile.write(str(uuid.uuid1()) + "\n")
102-
os.chmod(args.uuid_file, 0o644)
102+
os.chmod(args.uuid_file, 0o600)
103103

104104

105105
def sanitize_version(version):

dist/common/scripts/scylla_io_setup

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,5 +200,5 @@ if __name__ == "__main__":
200200
cpudata = scylla_cpuinfo()
201201
if not is_developer_mode():
202202
run_iotune()
203-
os.chmod(etcdir() + '/scylla.d/io_properties.yaml', 0o644)
204-
os.chmod(etcdir() + '/scylla.d/io.conf', 0o644)
203+
os.chmod(etcdir() + '/scylla.d/io_properties.yaml', 0o640)
204+
os.chmod(etcdir() + '/scylla.d/io.conf', 0o640)

dist/common/scripts/scylla_prepare

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def create_perftune_conf(cfg):
115115
yaml = out('/opt/scylladb/scripts/perftune.py ' + params)
116116
with open('/etc/scylla.d/perftune.yaml', 'w') as f:
117117
f.write(yaml)
118-
os.chmod('/etc/scylla.d/perftune.yaml', 0o644)
118+
os.chmod('/etc/scylla.d/perftune.yaml', 0o640)
119119
return True
120120
else:
121121
return False

dist/common/scripts/scylla_setup

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,16 @@ if __name__ == '__main__':
353353
cfg = sysconfig_parser(sysconfdir_p() / 'scylla-housekeeping')
354354
repo_files = cfg.get('REPO_FILES')
355355
for f in glob.glob(repo_files):
356-
os.chmod(f, 0o644)
356+
os.chmod(f, 0o640)
357357
with open('/etc/scylla.d/housekeeping.cfg', 'w') as f:
358358
f.write('[housekeeping]\ncheck-version: True\n')
359-
os.chmod('/etc/scylla.d/housekeeping.cfg', 0o644)
359+
os.chmod('/etc/scylla.d/housekeeping.cfg', 0o640)
360360
systemd_unit('scylla-housekeeping-daily.timer').unmask()
361361
systemd_unit('scylla-housekeeping-restart.timer').unmask()
362362
else:
363363
with open('/etc/scylla.d/housekeeping.cfg', 'w') as f:
364364
f.write('[housekeeping]\ncheck-version: False\n')
365-
os.chmod('/etc/scylla.d/housekeeping.cfg', 0o644)
365+
os.chmod('/etc/scylla.d/housekeeping.cfg', 0o640)
366366
hk_daily = systemd_unit('scylla-housekeeping-daily.timer')
367367
hk_daily.mask()
368368
hk_daily.stop()

test/cql-pytest/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def run_with_generated_dir(run_cmd_generator, run_dir_generator):
4646
(cmd, env) = run_cmd_generator(pid, dir)
4747
# redirect stdout and stderr to log file, as in a shell's >log 2>&1:
4848
log = os.path.join(dir, 'log')
49-
fd = os.open(log, os.O_WRONLY | os.O_CREAT | os.O_APPEND, mode=0o666)
49+
fd = os.open(log, os.O_WRONLY | os.O_CREAT | os.O_APPEND, mode=0o600)
5050
sys.stdout.flush()
5151
os.close(1)
5252
os.dup2(fd, 1)

test/nodetool/rest_api_mock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ async def catching_handler(request) -> aiohttp.web.Response:
198198
except Exception as e:
199199
tb = traceback.format_exc()
200200
logger.error(f'Exception when executing {handler.__name__}: {e}\n{tb}')
201-
return aiohttp.web.Response(status=500, text=str(e))
201+
return aiohttp.web.Response(status=500, text="Internal server error")
202202
return catching_handler
203203

204204
app.router.add_routes([

test/pylib/minio_server.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ def print_environ(self):
217217
msgs = []
218218
for key in self._get_environs():
219219
value = os.environ[key]
220+
if key in (self.ENV_ACCESS_KEY, self.ENV_SECRET_KEY):
221+
value = '<redacted>'
220222
msgs.append(f'export {key}={value}')
221223
print('\n'.join(msgs))
222224

test/pylib/scylla_cluster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ async def catching_handler(request) -> aiohttp.web.Response:
13411341
except Exception as e:
13421342
tb = traceback.format_exc()
13431343
self.logger.error(f'Exception when executing {handler.__name__}: {e}\n{tb}')
1344-
return aiohttp.web.Response(status=500, text=str(e))
1344+
return aiohttp.web.Response(status=500, text="Internal server error")
13451345
return catching_handler
13461346

13471347
def route_history_wrapper(blockable = False)-> Callable:

utils/managed_bytes.hh

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,16 +245,11 @@ public:
245245
auto first = new (p) multi_chunk_blob_storage(&_u.multi_chunk_ref, size, now);
246246
auto last = first;
247247
size -= now;
248-
try {
249-
while (size) {
250-
auto now = std::min(size_t(size), maxseg);
251-
void* p = alctr.alloc<multi_chunk_blob_storage>(sizeof(multi_chunk_blob_storage) + now);
252-
last = new (p) multi_chunk_blob_storage(&last->next, 0, now);
253-
size -= now;
254-
}
255-
} catch (...) {
256-
free_chain(first);
257-
throw;
248+
while (size) {
249+
auto now = std::min(size_t(size), maxseg);
250+
void* p = alctr.alloc<multi_chunk_blob_storage>(sizeof(multi_chunk_blob_storage) + now);
251+
last = new (p) multi_chunk_blob_storage(&last->next, 0, now);
252+
size -= now;
258253
}
259254
}
260255
}

0 commit comments

Comments
 (0)