mirror of
https://github.com/simon987/sist2.git
synced 2025-04-19 10:16:42 +00:00
sist2-admin: don't set status to failed when using debug binary
This commit is contained in:
parent
7eb064162e
commit
e2025df2c0
@ -134,7 +134,7 @@ export default {
|
|||||||
duration: this.taskDuration(row),
|
duration: this.taskDuration(row),
|
||||||
time: moment.utc(row.started).local().format("dd, MMM Do YYYY, HH:mm:ss"),
|
time: moment.utc(row.started).local().format("dd, MMM Do YYYY, HH:mm:ss"),
|
||||||
logs: null,
|
logs: null,
|
||||||
status: row.return_code === 0 ? "ok" : "failed",
|
status: [0,1].includes(row.return_code) ? "ok" : "failed",
|
||||||
_row: row
|
_row: row
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
@ -131,7 +131,9 @@ class Sist2ScanTask(Sist2Task):
|
|||||||
return_code = sist2.scan(self.job.scan_options, logs_cb=self.log_callback, set_pid_cb=set_pid)
|
return_code = sist2.scan(self.job.scan_options, logs_cb=self.log_callback, set_pid_cb=set_pid)
|
||||||
self.ended = datetime.utcnow()
|
self.ended = datetime.utcnow()
|
||||||
|
|
||||||
if return_code != 0:
|
is_ok = return_code in (0, 1)
|
||||||
|
|
||||||
|
if not is_ok:
|
||||||
self._logger.error(json.dumps({"sist2-admin": f"Process returned non-zero exit code ({return_code})"}))
|
self._logger.error(json.dumps({"sist2-admin": f"Process returned non-zero exit code ({return_code})"}))
|
||||||
logger.info(f"Task {self.display_name} failed ({return_code})")
|
logger.info(f"Task {self.display_name} failed ({return_code})")
|
||||||
else:
|
else:
|
||||||
@ -144,7 +146,7 @@ class Sist2ScanTask(Sist2Task):
|
|||||||
logger.info(f"Completed {self.display_name} ({return_code=})")
|
logger.info(f"Completed {self.display_name} ({return_code=})")
|
||||||
|
|
||||||
# Remove old index
|
# Remove old index
|
||||||
if return_code == 0:
|
if is_ok:
|
||||||
if self.job.previous_index_path is not None and self.job.previous_index_path != self.job.index_path:
|
if self.job.previous_index_path is not None and self.job.previous_index_path != self.job.index_path:
|
||||||
self._logger.info(json.dumps({"sist2-admin": f"Remove {self.job.previous_index_path=}"}))
|
self._logger.info(json.dumps({"sist2-admin": f"Remove {self.job.previous_index_path=}"}))
|
||||||
try:
|
try:
|
||||||
@ -247,7 +249,7 @@ class TaskQueue:
|
|||||||
def _tasks_failed(self):
|
def _tasks_failed(self):
|
||||||
done = set()
|
done = set()
|
||||||
|
|
||||||
for row in self._db["task_done"].sql("WHERE return_code != 0"):
|
for row in self._db["task_done"].sql("WHERE return_code NOT IN (0,1)"):
|
||||||
done.add(uuid.UUID(row["id"]))
|
done.add(uuid.UUID(row["id"]))
|
||||||
|
|
||||||
return done
|
return done
|
||||||
|
@ -241,7 +241,7 @@ class WebOptions(BaseModel):
|
|||||||
class Sist2:
|
class Sist2:
|
||||||
|
|
||||||
def __init__(self, bin_path: str, data_directory: str):
|
def __init__(self, bin_path: str, data_directory: str):
|
||||||
self._bin_path = bin_path
|
self.bin_path = bin_path
|
||||||
self._data_dir = data_directory
|
self._data_dir = data_directory
|
||||||
|
|
||||||
def index(self, options: IndexOptions, search_backend: Sist2SearchBackend, logs_cb):
|
def index(self, options: IndexOptions, search_backend: Sist2SearchBackend, logs_cb):
|
||||||
@ -254,7 +254,7 @@ class Sist2:
|
|||||||
search_backend.script_file = None
|
search_backend.script_file = None
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
self._bin_path,
|
self.bin_path,
|
||||||
*options.args(search_backend),
|
*options.args(search_backend),
|
||||||
"--json-logs",
|
"--json-logs",
|
||||||
"--very-verbose"
|
"--very-verbose"
|
||||||
@ -278,7 +278,7 @@ class Sist2:
|
|||||||
options.output = f"scan-{options.name.replace('/', '_')}-{datetime.utcnow()}.sist2"
|
options.output = f"scan-{options.name.replace('/', '_')}-{datetime.utcnow()}.sist2"
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
self._bin_path,
|
self.bin_path,
|
||||||
*options.args(),
|
*options.args(),
|
||||||
"--json-logs",
|
"--json-logs",
|
||||||
"--very-verbose"
|
"--very-verbose"
|
||||||
@ -336,7 +336,7 @@ class Sist2:
|
|||||||
options.auth0_public_key_file = None
|
options.auth0_public_key_file = None
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
self._bin_path,
|
self.bin_path,
|
||||||
*options.args(search_backend)
|
*options.args(search_backend)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user