diff --git a/.gitlab/ci/testing/.pretesting-gitlab-ci.yml b/.gitlab/ci/testing/.pretesting-gitlab-ci.yml index ba465a5c550..6c5155241c8 100644 --- a/.gitlab/ci/testing/.pretesting-gitlab-ci.yml +++ b/.gitlab/ci/testing/.pretesting-gitlab-ci.yml @@ -54,10 +54,10 @@ bandit: - mkdir /results - "bandit -r ${CI_PROJECT_DIR}/faraday -o /results/output.xml -f xml --skip B101" after_script: - - curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - + - wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg - apt update - apt-get install software-properties-common -y - - apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com focal main" + - echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/hashicorp.list - apt update - apt install vault -y - setcap cap_ipc_lock= /usr/bin/vault diff --git a/CHANGELOG/4.6.0/community.md b/CHANGELOG/4.6.0/community.md new file mode 100644 index 00000000000..69e7011a1ee --- /dev/null +++ b/CHANGELOG/4.6.0/community.md @@ -0,0 +1 @@ + * [FIX] Delete Cascade from KB. #7569 diff --git a/CHANGELOG/4.6.0/date.md b/CHANGELOG/4.6.0/date.md new file mode 100644 index 00000000000..22e2a907171 --- /dev/null +++ b/CHANGELOG/4.6.0/date.md @@ -0,0 +1 @@ +Sep 6th, 2023 diff --git a/RELEASE.md b/RELEASE.md index 920834f16d1..0bcb86d1c1c 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,6 +1,10 @@ New features in the latest update ===================================== +4.6.0 [Sep 6th, 2023]: +--- + * [FIX] Delete Cascade from KB. #7569 + 4.5.1 [Jul 15th, 2023]: --- * [FIX] Fix pillow version to 9.4.0. #7531 diff --git a/faraday/__init__.py b/faraday/__init__.py index 85c2b3e2296..05d1bb79587 100644 --- a/faraday/__init__.py +++ b/faraday/__init__.py @@ -4,5 +4,5 @@ See the file 'doc/LICENSE' for the license information """ -__version__ = '4.5.1' +__version__ = '4.6.0' __license_version__ = __version__ diff --git a/faraday/migrations/versions/61ded0c8fbf6_notification_center.py b/faraday/migrations/versions/61ded0c8fbf6_notification_center.py new file mode 100644 index 00000000000..ee4f1b6f709 --- /dev/null +++ b/faraday/migrations/versions/61ded0c8fbf6_notification_center.py @@ -0,0 +1,135 @@ +"""notification center + +Revision ID: 61ded0c8fbf6 +Revises: f20aa8756612 +Create Date: 2023-01-11 19:24:20.511853+00:00 + +""" +from alembic import op +import sqlalchemy as sa + +import faraday + +# revision identifiers, used by Alembic. +revision = '61ded0c8fbf6' +down_revision = 'dd3181b9b3e9' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('base_notification', + sa.Column('create_date', sa.DateTime(), nullable=True), + sa.Column('update_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('data', faraday.server.fields.JSONType(), nullable=False), + sa.Column('processed', sa.Boolean(), nullable=True), + sa.Column('creator_id', sa.Integer(), nullable=True), + sa.Column('update_user_id', sa.Integer(), nullable=True), + sa.Column('verbose', sa.Boolean(), nullable=False), + sa.ForeignKeyConstraint(['creator_id'], ['faraday_user.id'], ondelete='SET NULL'), + sa.ForeignKeyConstraint(['update_user_id'], ['faraday_user.id'], ondelete='SET NULL'), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('user_notification', + sa.Column('create_date', sa.DateTime(), nullable=True), + sa.Column('update_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('message', sa.Text(), nullable=False), + sa.Column('extra_data', faraday.server.fields.JSONType(), nullable=True), + sa.Column('type', sa.String(), nullable=False), + sa.Column('subtype', sa.String(), nullable=False), + sa.Column('read', sa.Boolean(), nullable=True), + sa.Column('user_id', sa.Integer(), nullable=False), + sa.Column('creator_id', sa.Integer(), nullable=True), + sa.Column('update_user_id', sa.Integer(), nullable=True), + sa.Column('triggered_by', faraday.server.fields.JSONType(), nullable=False), + sa.Column('links_to', faraday.server.fields.JSONType(), nullable=True), + sa.Column('event_date', sa.DateTime(), nullable=False), + sa.ForeignKeyConstraint(['creator_id'], ['faraday_user.id'], ondelete='SET NULL'), + sa.ForeignKeyConstraint(['update_user_id'], ['faraday_user.id'], ondelete='SET NULL'), + sa.ForeignKeyConstraint(['user_id'], ['faraday_user.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_user_notification_user_id'), 'user_notification', ['user_id'], unique=False) + op.create_table('user_notification_settings', + sa.Column('create_date', sa.DateTime(), nullable=True), + sa.Column('update_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('user_id', sa.Integer(), nullable=False), + sa.Column('paused', sa.Boolean(), nullable=False), + sa.Column('slack_id', sa.String(), nullable=True), + sa.Column('no_self_notify', sa.Boolean(), nullable=False), + sa.Column('agents_enabled', sa.Boolean(), nullable=False), + sa.Column('agents_app', sa.Boolean(), nullable=False), + sa.Column('agents_email', sa.Boolean(), nullable=False), + sa.Column('agents_slack', sa.Boolean(), nullable=False), + sa.Column('cli_enabled', sa.Boolean(), nullable=False), + sa.Column('cli_app', sa.Boolean(), nullable=False), + sa.Column('cli_email', sa.Boolean(), nullable=False), + sa.Column('cli_slack', sa.Boolean(), nullable=False), + sa.Column('comments_enabled', sa.Boolean(), nullable=False), + sa.Column('comments_app', sa.Boolean(), nullable=False), + sa.Column('comments_email', sa.Boolean(), nullable=False), + sa.Column('comments_slack', sa.Boolean(), nullable=False), + sa.Column('hosts_enabled', sa.Boolean(), nullable=False), + sa.Column('hosts_app', sa.Boolean(), nullable=False), + sa.Column('hosts_email', sa.Boolean(), nullable=False), + sa.Column('hosts_slack', sa.Boolean(), nullable=False), + sa.Column('users_enabled', sa.Boolean(), nullable=False), + sa.Column('users_app', sa.Boolean(), nullable=False), + sa.Column('users_email', sa.Boolean(), nullable=False), + sa.Column('users_slack', sa.Boolean(), nullable=False), + sa.Column('reports_enabled', sa.Boolean(), nullable=False), + sa.Column('reports_app', sa.Boolean(), nullable=False), + sa.Column('reports_email', sa.Boolean(), nullable=False), + sa.Column('reports_slack', sa.Boolean(), nullable=False), + sa.Column('vulnerabilities_enabled', sa.Boolean(), nullable=False), + sa.Column('vulnerabilities_app', sa.Boolean(), nullable=False), + sa.Column('vulnerabilities_email', sa.Boolean(), nullable=False), + sa.Column('vulnerabilities_slack', sa.Boolean(), nullable=False), + sa.Column('workspaces_enabled', sa.Boolean(), nullable=False), + sa.Column('workspaces_app', sa.Boolean(), nullable=False), + sa.Column('workspaces_email', sa.Boolean(), nullable=False), + sa.Column('workspaces_slack', sa.Boolean(), nullable=False), + sa.Column('pipelines_enabled', sa.Boolean(), nullable=False), + sa.Column('pipelines_app', sa.Boolean(), nullable=False), + sa.Column('pipelines_email', sa.Boolean(), nullable=False), + sa.Column('pipelines_slack', sa.Boolean(), nullable=False), + sa.Column('executive_reports_enabled', sa.Boolean(), nullable=False), + sa.Column('executive_reports_app', sa.Boolean(), nullable=False), + sa.Column('executive_reports_email', sa.Boolean(), nullable=False), + sa.Column('executive_reports_slack', sa.Boolean(), nullable=False), + sa.Column('planner_enabled', sa.Boolean(), nullable=False), + sa.Column('planner_app', sa.Boolean(), nullable=False), + sa.Column('planner_email', sa.Boolean(), nullable=False), + sa.Column('planner_slack', sa.Boolean(), nullable=False), + sa.Column('integrations_enabled', sa.Boolean(), nullable=False), + sa.Column('integrations_app', sa.Boolean(), nullable=False), + sa.Column('integrations_email', sa.Boolean(), nullable=False), + sa.Column('integrations_slack', sa.Boolean(), nullable=False), + sa.Column('other_enabled', sa.Boolean(), nullable=False), + sa.Column('other_app', sa.Boolean(), nullable=False), + sa.Column('other_email', sa.Boolean(), nullable=False), + sa.Column('other_slack', sa.Boolean(), nullable=False), + sa.Column('adv_high_crit_vuln', sa.Boolean(), nullable=False), + sa.Column('adv_risk_score_threshold', sa.Integer(), nullable=False), + sa.Column('adv_vuln_open_days', sa.Integer(), nullable=False), + sa.Column('creator_id', sa.Integer(), nullable=True), + sa.Column('update_user_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['creator_id'], ['faraday_user.id'], ondelete='SET NULL'), + sa.ForeignKeyConstraint(['update_user_id'], ['faraday_user.id'], ondelete='SET NULL'), + sa.ForeignKeyConstraint(['user_id'], ['faraday_user.id'], ), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('user_notification_settings') + op.drop_index(op.f('ix_user_notification_user_id'), table_name='user_notification') + op.drop_table('user_notification') + op.drop_table('base_notification') + # ### end Alembic commands ### diff --git a/faraday/migrations/versions/73854f804a8d_cascade_kb_2.py b/faraday/migrations/versions/73854f804a8d_cascade_kb_2.py new file mode 100644 index 00000000000..2391260295f --- /dev/null +++ b/faraday/migrations/versions/73854f804a8d_cascade_kb_2.py @@ -0,0 +1,31 @@ +"""cascade KB 2 + +Revision ID: 73854f804a8d +Revises: 61ded0c8fbf6 +Create Date: 2023-08-31 17:16:51.813227+00:00 + +""" +from alembic import op + + +# revision identifiers, used by Alembic. +revision = '73854f804a8d' +down_revision = '61ded0c8fbf6' +branch_labels = None +depends_on = None + + +def upgrade(): + op.execute('ALTER TABLE policy_violation_template_vulnerability_association DROP CONSTRAINT policy_violation_template_vulnerability_a_vulnerability_id_fkey') + op.execute('ALTER TABLE policy_violation_template_vulnerability_association ADD CONSTRAINT policy_violation_template_vulnerability_a_vulnerability_id_fkey FOREIGN KEY (vulnerability_id) REFERENCES vulnerability_template (id) ON DELETE CASCADE') + + op.execute('ALTER TABLE reference_template_vulnerability_association DROP CONSTRAINT reference_template_vulnerability_associat_vulnerability_id_fkey') + op.execute('ALTER TABLE reference_template_vulnerability_association ADD CONSTRAINT reference_template_vulnerability_associat_vulnerability_id_fkey FOREIGN KEY (vulnerability_id) REFERENCES vulnerability_template (id) ON DELETE CASCADE') + + +def downgrade(): + op.execute('ALTER TABLE policy_violation_template_vulnerability_association DROP CONSTRAINT policy_violation_template_vulnerability_a_vulnerability_id_fkey') + op.execute('ALTER TABLE policy_violation_template_vulnerability_association ADD CONSTRAINT policy_violation_template_vulnerability_a_vulnerability_id_fkey FOREIGN KEY (vulnerability_id) REFERENCES vulnerability_template (id)') + + op.execute('ALTER TABLE reference_template_vulnerability_association DROP CONSTRAINT reference_template_vulnerability_associat_vulnerability_id_fkey') + op.execute('ALTER TABLE reference_template_vulnerability_association ADD CONSTRAINT reference_template_vulnerability_associat_vulnerability_id_fkey FOREIGN KEY (vulnerability_id) REFERENCES vulnerability_template (id)') diff --git a/faraday/openapi/faraday_swagger.json b/faraday/openapi/faraday_swagger.json index 723a43468ef..c6c9135388d 100644 --- a/faraday/openapi/faraday_swagger.json +++ b/faraday/openapi/faraday_swagger.json @@ -1,7 +1,7 @@ { "info": { "description": "The Faraday REST API enables you to interact with [our server](https://github.com/infobyte/faraday).\nUse this API to interact or integrate with Faraday server. This page documents the REST API, with HTTP response codes and example requests and responses.", - "title": "Faraday 4.5.0 API", + "title": "Faraday 4.6.0 API", "version": "v3" }, "security": { @@ -4176,41 +4176,48 @@ "Command": { "type": "object", "properties": { - "hostname": { + "_id": { + "type": "integer", + "readOnly": true + }, + "command": { "type": "string", "nullable": true, - "maxLength": 250 + "minLength": 1 }, + "duration": { + "nullable": true + }, + "itime": {}, "ip": { "type": "string", "nullable": true, "maxLength": 250 }, - "tool": { + "hostname": { "type": "string", "nullable": true, - "minLength": 1 + "maxLength": 250 }, - "command": { + "params": { + "type": "string", + "nullable": true + }, + "user": { "type": "string", "nullable": true, - "minLength": 1 + "maxLength": 250 }, - "_id": { - "type": "integer", + "creator": { "readOnly": true }, - "metadata": {}, - "params": { - "type": "string", - "nullable": true - }, - "itime": {}, "workspace": { "readOnly": true }, - "duration": { - "nullable": true + "tool": { + "type": "string", + "nullable": true, + "minLength": 1 }, "import_source": { "enum": [ @@ -4221,14 +4228,7 @@ "nullable": true, "maxLength": 6 }, - "creator": { - "readOnly": true - }, - "user": { - "type": "string", - "nullable": true, - "maxLength": 250 - } + "metadata": {} }, "required": [ "command", @@ -4239,53 +4239,41 @@ "ActivityFeed": { "type": "object", "properties": { - "ip": { - "type": "string", - "nullable": true, - "maxLength": 250 - }, "_id": { "type": "integer", "readOnly": true }, - "sum_created_vulnerability_high": { - "type": "integer", - "readOnly": true - }, - "hostname": { + "command": { "type": "string", "nullable": true, - "maxLength": 250 + "minLength": 1 }, - "tool": { + "ip": { "type": "string", "nullable": true, - "minLength": 1 + "maxLength": 250 }, - "command": { + "hostname": { "type": "string", "nullable": true, - "minLength": 1 + "maxLength": 250 }, - "sum_created_vulnerabilities": { - "readOnly": true, + "params": { + "type": "string", "nullable": true }, - "workspace": { - "readOnly": true - }, - "itime": {}, - "sum_created_vulnerability_medium": { - "type": "integer", - "readOnly": true + "user": { + "type": "string", + "nullable": true, + "maxLength": 250 }, - "sum_created_vulnerability_low": { - "type": "integer", + "workspace": { "readOnly": true }, - "sum_created_vulnerability_unclassified": { - "type": "integer", - "readOnly": true + "tool": { + "type": "string", + "nullable": true, + "minLength": 1 }, "import_source": { "enum": [ @@ -4296,33 +4284,45 @@ "nullable": true, "maxLength": 6 }, - "user": { - "type": "string", - "nullable": true, - "maxLength": 250 - }, - "creator": { - "readOnly": true + "itime": {}, + "sum_created_vulnerabilities": { + "readOnly": true, + "nullable": true }, "sum_created_hosts": { "readOnly": true, "nullable": true }, + "sum_created_services": { + "readOnly": true, + "nullable": true + }, "sum_created_vulnerability_critical": { "type": "integer", "readOnly": true }, - "params": { - "type": "string", - "nullable": true + "sum_created_vulnerability_high": { + "type": "integer", + "readOnly": true }, - "sum_created_services": { - "readOnly": true, - "nullable": true + "sum_created_vulnerability_medium": { + "type": "integer", + "readOnly": true + }, + "sum_created_vulnerability_low": { + "type": "integer", + "readOnly": true }, "sum_created_vulnerability_info": { "type": "integer", "readOnly": true + }, + "sum_created_vulnerability_unclassified": { + "type": "integer", + "readOnly": true + }, + "creator": { + "readOnly": true } }, "required": [ @@ -4334,55 +4334,55 @@ "Credential": { "type": "object", "properties": { - "parent": {}, - "host_ip": { - "type": "string", + "id": { + "type": "integer" + }, + "_id": { + "type": "integer", "readOnly": true }, "_rev": { "type": "string", "readOnly": true }, - "couchdbid": { - "type": "string" - }, - "service_name": { + "parent": {}, + "username": { "type": "string", - "readOnly": true - }, - "id": { - "type": "integer" + "minLength": 1 }, - "_id": { - "type": "integer", - "readOnly": true + "description": { + "type": "string" }, "name": { "type": "string", "nullable": true }, - "metadata": {}, + "password": { + "type": "string" + }, "owner": { "type": "string", "readOnly": true }, - "target": { - "type": "string", + "owned": { + "type": "boolean", "readOnly": true }, - "username": { - "type": "string", - "minLength": 1 - }, - "description": { + "couchdbid": { "type": "string" }, "parent_type": {}, - "password": { - "type": "string" + "metadata": {}, + "host_ip": { + "type": "string", + "readOnly": true }, - "owned": { - "type": "boolean", + "service_name": { + "type": "string", + "readOnly": true + }, + "target": { + "type": "string", "readOnly": true } }, @@ -4395,25 +4395,46 @@ "Host": { "type": "object", "properties": { + "id": { + "type": "integer" + }, + "_id": { + "type": "integer", + "readOnly": true + }, + "_rev": { + "type": "string", + "readOnly": true + }, "ip": { "type": "string" }, - "versions": { - "readOnly": true + "description": { + "type": "string" }, - "_id": { + "mac": { + "type": "string", + "nullable": true + }, + "credentials": { "type": "integer", "readOnly": true }, - "vulns": { + "default_gateway": { + "type": "string", + "nullable": true + }, + "metadata": {}, + "name": { + "type": "string", "readOnly": true }, + "os": { + "type": "string" + }, "owned": { "type": "boolean" }, - "severity_counts": { - "readOnly": true - }, "owner": { "readOnly": true }, @@ -4421,50 +4442,29 @@ "type": "integer", "readOnly": true }, - "command_id": { - "type": "integer", - "writeOnly": true - }, - "os": { - "type": "string" - }, - "type": { + "vulns": { "readOnly": true }, - "importance": { - "type": "integer" - }, "hostnames": {}, - "metadata": {}, - "name": { - "type": "string", + "type": { "readOnly": true }, - "default_gateway": { - "type": "string", - "nullable": true - }, - "description": { - "type": "string" - }, - "credentials": { - "type": "integer", + "service_summaries": { "readOnly": true }, - "_rev": { - "type": "string", + "versions": { "readOnly": true }, - "id": { + "importance": { "type": "integer" }, - "mac": { - "type": "string", - "nullable": true - }, - "service_summaries": { + "severity_counts": { "readOnly": true - } + }, + "command_id": { + "type": "integer", + "writeOnly": true + } }, "required": [ "description" @@ -4473,14 +4473,11 @@ "HostCount": { "type": "object", "properties": { - "total": { - "readOnly": true - }, - "critical": { + "host_id": { "type": "integer", "readOnly": true }, - "info": { + "critical": { "type": "integer", "readOnly": true }, @@ -4496,13 +4493,16 @@ "type": "integer", "readOnly": true }, - "host_id": { + "info": { "type": "integer", "readOnly": true }, "unclassified": { "type": "integer", "readOnly": true + }, + "total": { + "readOnly": true } } }, @@ -4513,25 +4513,13 @@ "Service": { "type": "object", "properties": { - "version": { - "type": "string", - "nullable": true + "id": { + "type": "integer" }, "_id": { "type": "integer", "readOnly": true }, - "vulns": { - "type": "integer", - "readOnly": true - }, - "host_id": { - "type": "integer", - "readOnly": true - }, - "owned": { - "type": "boolean" - }, "status": { "type": "string", "default": "open", @@ -4541,53 +4529,65 @@ "filtered" ] }, - "owner": { - "readOnly": true - }, - "command_id": { - "type": "integer", - "writeOnly": true - }, "parent": { "type": "integer" }, + "type": { + "readOnly": true + }, "protocol": { "type": "string", "nullable": true, "minLength": 1 }, - "summary": { + "description": { + "type": "string", + "nullable": true + }, + "_rev": { "type": "string", "readOnly": true }, - "type": { + "owned": { + "type": "boolean" + }, + "owner": { + "readOnly": true + }, + "credentials": { + "type": "integer", + "readOnly": true + }, + "vulns": { + "type": "integer", "readOnly": true }, - "metadata": {}, "name": { "type": "string", "nullable": true }, - "ports": {}, - "description": { + "version": { "type": "string", "nullable": true }, - "credentials": { + "port": { "type": "integer", - "readOnly": true + "readOnly": true, + "minimum": 0 }, - "_rev": { + "ports": {}, + "metadata": {}, + "summary": { "type": "string", "readOnly": true }, - "port": { + "host_id": { "type": "integer", - "readOnly": true, - "minimum": 0 + "readOnly": true }, - "id": { - "type": "integer" + "command_id": { + "type": "integer", + "writeOnly": true } }, "required": [ @@ -4599,33 +4599,33 @@ "License": { "type": "object", "properties": { - "start": { - "type": "string", - "format": "date-time" + "_id": { + "type": "integer", + "readOnly": true + }, + "id": { + "type": "integer" }, "product": { "type": "string", "nullable": true, "minLength": 1 }, - "lictype": { + "start": { "type": "string", - "nullable": true - }, - "_id": { - "type": "integer", - "readOnly": true + "format": "date-time" }, - "id": { - "type": "integer" + "end": { + "type": "string", + "format": "date-time" }, - "notes": { + "lictype": { "type": "string", "nullable": true }, - "end": { + "notes": { "type": "string", - "format": "date-time" + "nullable": true } }, "required": [ @@ -4635,18 +4635,11 @@ "Service1": { "type": "object", "properties": { - "version": { - "type": "string", - "nullable": true - }, "_id": { "type": "integer", "readOnly": true }, - "name": { - "type": "string", - "nullable": true - }, + "ports": {}, "status": { "type": "string", "default": "open", @@ -4661,11 +4654,18 @@ "nullable": true, "minLength": 1 }, + "name": { + "type": "string", + "nullable": true + }, + "version": { + "type": "string", + "nullable": true + }, "summary": { "type": "string", "readOnly": true - }, - "ports": {} + } }, "required": [ "ports", @@ -4686,50 +4686,10 @@ "VulnerabilityWeb": { "type": "object", "properties": { - "pname": { - "type": "string" - }, - "confirmed": { - "type": "boolean" - }, - "query": { - "type": "string" - }, - "_attachments": {}, "_id": { "type": "integer", "readOnly": true }, - "cwe": { - "type": "array", - "items": { - "type": "string" - } - }, - "response": { - "type": "string" - }, - "owned": { - "type": "boolean", - "readOnly": true - }, - "data": { - "type": "string", - "nullable": true - }, - "cvss2": {}, - "tool": { - "type": "string" - }, - "service": { - "readOnly": true, - "allOf": [ - { - "$ref": "#/components/schemas/Service1" - } - ] - }, - "impact": {}, "status": { "enum": [ "open", @@ -4739,129 +4699,169 @@ "opened" ] }, - "owner": { + "parent_type": {}, + "website": { + "type": "string" + }, + "issuetracker": { "readOnly": true }, - "target": { + "description": { "type": "string", "readOnly": true }, - "owasp": { - "type": "array", - "readOnly": true, - "items": { - "type": "string" - } - }, + "parent": {}, "tags": { "readOnly": true }, - "refs": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Reference" - } - }, - "issuetracker": { - "readOnly": true - }, - "parent_type": {}, - "desc": { + "severity": { "type": "string" }, - "website": { - "type": "string" + "_rev": { + "type": "string", + "readOnly": true }, - "resolution": { + "easeofresolution": { "type": "string", + "enum": [ + "trivial", + "simple", + "moderate", + "difficult", + "infeasible" + ], "nullable": true }, - "command_id": { - "type": "integer", - "writeOnly": true - }, - "parent": {}, - "severity": { - "type": "string" + "owned": { + "type": "boolean", + "readOnly": true }, - "type": {}, - "custom_fields": {}, "hostnames": { "readOnly": true }, - "path": { + "pname": { "type": "string" }, - "name": { - "type": "string", - "nullable": true, - "minLength": 1 - }, - "policyviolations": { - "type": "array", - "items": { - "type": "string" - } - }, - "method": { + "query": { "type": "string" }, - "metadata": {}, - "risk": { + "owner": { "readOnly": true }, - "host_os": { - "type": "string", - "readOnly": true + "path": { + "type": "string" }, - "description": { + "date": { "type": "string", + "format": "date-time", "readOnly": true }, - "cvss3": {}, - "_rev": { + "data": { "type": "string", - "readOnly": true - }, - "status_code": { - "type": "integer", "nullable": true }, - "cve": { + "response": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "impact": {}, + "confirmed": { + "type": "boolean" + }, + "name": { + "type": "string", + "nullable": true, + "minLength": 1 + }, + "service": { + "readOnly": true, + "allOf": [ + { + "$ref": "#/components/schemas/Service1" + } + ] + }, + "obj_id": { + "type": "string", + "readOnly": true + }, + "type": {}, + "policyviolations": { "type": "array", "items": { "type": "string" } }, - "external_id": { + "request": { + "type": "string" + }, + "_attachments": {}, + "params": { + "type": "string" + }, + "target": { "type": "string", - "nullable": true + "readOnly": true }, - "date": { + "host_os": { "type": "string", - "format": "date-time", "readOnly": true }, - "params": { + "resolution": { + "type": "string", + "nullable": true + }, + "method": { "type": "string" }, - "easeofresolution": { + "metadata": {}, + "status_code": { + "type": "integer", + "nullable": true + }, + "custom_fields": {}, + "external_id": { "type": "string", - "enum": [ - "trivial", - "simple", - "moderate", - "difficult", - "infeasible" - ], "nullable": true }, - "request": { + "tool": { "type": "string" }, + "cve": { + "type": "array", + "items": { + "type": "string" + } + }, + "cwe": { + "type": "array", + "items": { + "type": "string" + } + }, + "owasp": { + "type": "array", + "readOnly": true, + "items": { + "type": "string" + } + }, + "cvss2": {}, + "cvss3": {}, + "refs": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Reference" + } + }, "reference_instances": {}, - "obj_id": { - "type": "string", + "command_id": { + "type": "integer", + "writeOnly": true + }, + "risk": { "readOnly": true } }, @@ -4887,27 +4887,39 @@ "VulnerabilityTemplate": { "type": "object", "properties": { + "id": { + "type": "integer", + "readOnly": true + }, "_id": { "type": "integer", "readOnly": true }, - "create_at": { + "_rev": { "type": "string", - "format": "date-time", "readOnly": true }, "cwe": { "type": "string", "readOnly": true }, - "data": { - "type": "string" + "description": { + "type": "string", + "nullable": true }, - "creator_id": { - "type": "integer", + "desc": { + "type": "string", "readOnly": true }, - "impact": {}, + "exploitation": { + "type": "string" + }, + "name": { + "type": "string", + "nullable": true, + "minLength": 1 + }, + "references": {}, "refs": { "type": "array", "readOnly": true, @@ -4915,15 +4927,20 @@ "type": "string" } }, - "exploitation": { - "type": "string" - }, - "desc": { + "resolution": { "type": "string", - "readOnly": true + "nullable": true }, - "resolution": { + "impact": {}, + "easeofresolution": { "type": "string", + "enum": [ + "trivial", + "simple", + "moderate", + "difficult", + "infeasible" + ], "nullable": true }, "policyviolations": { @@ -4932,43 +4949,26 @@ "type": "string" } }, - "name": { - "type": "string", - "nullable": true, - "minLength": 1 + "data": { + "type": "string" }, - "customfields": {}, - "description": { + "external_id": { "type": "string", "nullable": true }, "creator": { "readOnly": true }, - "_rev": { + "create_at": { "type": "string", + "format": "date-time", "readOnly": true }, - "references": {}, - "external_id": { - "type": "string", - "nullable": true - }, - "id": { + "creator_id": { "type": "integer", "readOnly": true }, - "easeofresolution": { - "type": "string", - "enum": [ - "trivial", - "simple", - "moderate", - "difficult", - "infeasible" - ], - "nullable": true - } + "customfields": {} }, "required": [ "exploitation", @@ -4978,23 +4978,23 @@ "Histogram": { "type": "object", "properties": { - "critical": { - "type": "integer", + "date": { + "type": "string", "readOnly": true }, - "confirmed": { + "medium": { "type": "integer", "readOnly": true }, - "medium": { + "high": { "type": "integer", "readOnly": true }, - "date": { - "type": "string", + "critical": { + "type": "integer", "readOnly": true }, - "high": { + "confirmed": { "type": "integer", "readOnly": true } @@ -5003,24 +5003,6 @@ "Workspace": { "type": "object", "properties": { - "active": { - "type": "boolean" - }, - "histogram": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Histogram" - } - }, - "stats": {}, - "last_run_agent_date": { - "type": "string", - "format": "date-time", - "readOnly": true - }, - "importance": { - "type": "integer" - }, "_id": { "type": "integer", "readOnly": true @@ -5028,9 +5010,27 @@ "id": { "type": "integer" }, + "customer": { + "type": "string", + "nullable": true, + "maxLength": 250 + }, + "description": { + "type": "string", + "nullable": true + }, + "active": { + "type": "boolean" + }, + "duration": {}, "name": { "type": "string" }, + "public": { + "type": "boolean" + }, + "scope": {}, + "stats": {}, "create_date": { "type": "string", "format": "date-time", @@ -5041,23 +5041,23 @@ "format": "date-time", "readOnly": true }, - "duration": {}, "readonly": { "type": "boolean" }, - "description": { + "last_run_agent_date": { "type": "string", - "nullable": true - }, - "public": { - "type": "boolean" + "format": "date-time", + "readOnly": true }, - "customer": { - "type": "string", - "nullable": true, - "maxLength": 250 + "histogram": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Histogram" + } }, - "scope": {} + "importance": { + "type": "integer" + } }, "required": [ "name" @@ -5094,28 +5094,28 @@ "CustomFieldsSchema": { "type": "object", "properties": { - "field_display_name": { - "type": "string" - }, - "field_name": { - "type": "string" - }, "id": { "type": "integer", "readOnly": true }, + "field_name": { + "type": "string" + }, "field_type": { "type": "string" }, - "field_order": { + "field_metadata": { + "type": "string", + "nullable": true + }, + "field_display_name": { + "type": "string" + }, + "field_order": { "type": "integer" }, "table_name": { "type": "string" - }, - "field_metadata": { - "type": "string", - "nullable": true } }, "required": [ @@ -5144,21 +5144,25 @@ "Executor": { "type": "object", "properties": { - "parameters_metadata": { - "type": "object", + "id": { + "type": "integer", "readOnly": true }, - "last_run": { + "name": { "type": "string", - "format": "date-time", "readOnly": true }, - "id": { + "agent_id": { "type": "integer", "readOnly": true }, - "name": { + "last_run": { "type": "string", + "format": "date-time", + "readOnly": true + }, + "parameters_metadata": { + "type": "object", "readOnly": true }, "schedules": { @@ -5168,29 +5172,12 @@ "$ref": "#/components/schemas/AgentsSchedule" } ] - }, - "agent_id": { - "type": "integer", - "readOnly": true } } }, "Agent": { "type": "object", "properties": { - "active": { - "type": "boolean", - "nullable": true - }, - "is_online": { - "type": "boolean", - "readOnly": true - }, - "last_run": { - "type": "string", - "format": "date-time", - "readOnly": true - }, "id": { "type": "integer" }, @@ -5203,6 +5190,10 @@ "type": "string", "readOnly": true }, + "active": { + "type": "boolean", + "nullable": true + }, "create_date": { "type": "string", "format": "date-time", @@ -5213,6 +5204,13 @@ "format": "date-time", "readOnly": true }, + "creator": { + "readOnly": true + }, + "is_online": { + "type": "boolean", + "readOnly": true + }, "executors": { "readOnly": true, "allOf": [ @@ -5221,7 +5219,9 @@ } ] }, - "creator": { + "last_run": { + "type": "string", + "format": "date-time", "readOnly": true } }, @@ -5235,10 +5235,10 @@ "token": { "type": "string" }, - "total_duration": { + "expires_in": { "type": "number" }, - "expires_in": { + "total_duration": { "type": "number" } }, @@ -5248,140 +5248,144 @@ "total_duration" ] }, - "Vulnerability": { + "BulkCredential": { "type": "object", "properties": { - "confirmed": { - "type": "boolean" - }, - "_attachments": {}, - "_id": { - "type": "integer", - "readOnly": true - }, - "cwe": { - "type": "array", - "items": { - "type": "string" - } + "username": { + "type": "string", + "nullable": true }, - "owned": { - "type": "boolean", - "readOnly": true + "password": { + "type": "string", + "nullable": true }, - "data": { + "description": { "type": "string", "nullable": true }, - "cvss2": {}, - "tool": { - "type": "string" + "name": { + "type": "string", + "nullable": true + } + } + }, + "BulkService": { + "type": "object", + "properties": { + "id": { + "type": "integer" }, - "service": { - "readOnly": true, - "allOf": [ - { - "$ref": "#/components/schemas/Service1" - } - ] + "_id": { + "type": "integer", + "readOnly": true }, - "impact": {}, "status": { + "type": "string", + "default": "open", "enum": [ "open", "closed", - "re-opened", - "risk-accepted", - "opened" + "filtered" ] }, - "owner": { + "type": { "readOnly": true }, - "target": { + "protocol": { + "type": "string", + "nullable": true, + "minLength": 1 + }, + "description": { + "type": "string", + "nullable": true + }, + "_rev": { "type": "string", "readOnly": true }, - "owasp": { - "type": "array", - "readOnly": true, - "items": { - "type": "string" - } + "owned": { + "type": "boolean" }, - "tags": { + "owner": { "readOnly": true }, - "refs": { + "credentials": { + "default": [], "type": "array", "items": { - "$ref": "#/components/schemas/Reference" + "$ref": "#/components/schemas/BulkCredential" } }, - "issuetracker": { + "vulns": { + "type": "integer", "readOnly": true }, - "desc": { - "type": "string" + "name": { + "type": "string", + "nullable": true }, - "resolution": { + "version": { "type": "string", "nullable": true }, - "command_id": { + "port": { "type": "integer", - "writeOnly": true - }, - "run_date": {}, - "severity": { - "type": "string" + "minimum": 0 }, - "type": {}, - "custom_fields": {}, - "hostnames": { + "metadata": {}, + "summary": { + "type": "string", "readOnly": true }, - "policyviolations": { - "type": "array", - "items": { - "type": "string" - } + "host_id": { + "type": "integer", + "readOnly": true }, - "name": { - "type": "string", - "nullable": true, - "minLength": 1 + "command_id": { + "type": "integer", + "writeOnly": true }, - "metadata": {}, - "risk": { + "vulnerabilities": { + "default": [] + } + }, + "required": [ + "port", + "protocol" + ] + }, + "Vulnerability": { + "type": "object", + "properties": { + "_id": { + "type": "integer", "readOnly": true }, - "host_os": { - "type": "string", + "status": { + "enum": [ + "open", + "closed", + "re-opened", + "risk-accepted", + "opened" + ] + }, + "issuetracker": { "readOnly": true }, "description": { "type": "string", "readOnly": true }, - "cvss3": {}, - "_rev": { - "type": "string", + "tags": { "readOnly": true }, - "cve": { - "type": "array", - "items": { - "type": "string" - } - }, - "external_id": { - "type": "string", - "nullable": true + "severity": { + "type": "string" }, - "date": { + "_rev": { "type": "string", - "format": "date-time", "readOnly": true }, "easeofresolution": { @@ -5395,154 +5399,167 @@ ], "nullable": true }, - "reference_instances": {}, - "obj_id": { - "type": "string", + "owned": { + "type": "boolean", "readOnly": true - } - }, - "required": [ - "name", - "severity", - "type" - ] - }, - "BulkCredential": { - "type": "object", - "properties": { - "name": { - "type": "string", - "nullable": true - }, - "username": { - "type": "string", - "nullable": true }, - "description": { - "type": "string", - "nullable": true - }, - "password": { - "type": "string", - "nullable": true - } - } - }, - "BulkService": { - "type": "object", - "properties": { - "version": { - "type": "string", - "nullable": true - }, - "_id": { - "type": "integer", + "hostnames": { "readOnly": true }, - "vulnerabilities": { - "default": [] - }, - "vulns": { - "type": "integer", + "owner": { "readOnly": true }, - "host_id": { - "type": "integer", + "date": { + "type": "string", + "format": "date-time", "readOnly": true }, - "owned": { - "type": "boolean" - }, - "status": { + "data": { "type": "string", - "default": "open", - "enum": [ - "open", - "closed", - "filtered" - ] + "nullable": true }, - "owner": { - "readOnly": true + "desc": { + "type": "string" }, - "command_id": { - "type": "integer", - "writeOnly": true + "impact": {}, + "confirmed": { + "type": "boolean" }, - "protocol": { + "name": { "type": "string", "nullable": true, "minLength": 1 }, - "summary": { + "service": { + "readOnly": true, + "allOf": [ + { + "$ref": "#/components/schemas/Service1" + } + ] + }, + "obj_id": { "type": "string", "readOnly": true }, - "type": { + "type": {}, + "policyviolations": { + "type": "array", + "items": { + "type": "string" + } + }, + "_attachments": {}, + "target": { + "type": "string", "readOnly": true }, - "metadata": {}, - "name": { + "host_os": { + "type": "string", + "readOnly": true + }, + "resolution": { "type": "string", "nullable": true }, - "description": { + "metadata": {}, + "custom_fields": {}, + "external_id": { "type": "string", "nullable": true }, - "credentials": { - "default": [], + "tool": { + "type": "string" + }, + "cvss2": {}, + "cvss3": {}, + "cwe": { "type": "array", "items": { - "$ref": "#/components/schemas/BulkCredential" + "type": "string" } }, - "_rev": { - "type": "string", - "readOnly": true + "cve": { + "type": "array", + "items": { + "type": "string" + } }, - "port": { + "owasp": { + "type": "array", + "readOnly": true, + "items": { + "type": "string" + } + }, + "refs": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Reference" + } + }, + "reference_instances": {}, + "command_id": { "type": "integer", - "minimum": 0 + "writeOnly": true }, - "id": { - "type": "integer" - } + "risk": { + "readOnly": true + }, + "run_date": {} }, "required": [ - "port", - "protocol" + "name", + "severity", + "type" ] }, "HostBulk": { "type": "object", "properties": { - "ip": { - "type": "string" - }, - "versions": { - "readOnly": true + "id": { + "type": "integer" }, "_id": { "type": "integer", "readOnly": true }, - "vulnerabilities": { + "_rev": { + "type": "string", + "readOnly": true + }, + "ip": { + "type": "string" + }, + "description": { + "type": "string" + }, + "mac": { + "type": "string", + "nullable": true + }, + "credentials": { "default": [], "type": "array", "items": { - "$ref": "#/components/schemas/Vulnerability" + "$ref": "#/components/schemas/BulkCredential" } }, - "vulns": { + "default_gateway": { + "type": "string", + "nullable": true + }, + "metadata": {}, + "name": { + "type": "string", "readOnly": true }, + "os": { + "type": "string" + }, "owned": { "type": "boolean" }, - "severity_counts": { - "readOnly": true - }, "owner": { "readOnly": true }, @@ -5553,52 +5570,35 @@ "$ref": "#/components/schemas/BulkService" } }, - "command_id": { - "type": "integer", - "writeOnly": true - }, - "os": { - "type": "string" + "vulns": { + "readOnly": true }, + "hostnames": {}, "type": { "readOnly": true }, + "service_summaries": { + "readOnly": true + }, + "versions": { + "readOnly": true + }, "importance": { "type": "integer" }, - "hostnames": {}, - "metadata": {}, - "name": { - "type": "string", + "severity_counts": { "readOnly": true }, - "default_gateway": { - "type": "string", - "nullable": true - }, - "description": { - "type": "string" + "command_id": { + "type": "integer", + "writeOnly": true }, - "credentials": { + "vulnerabilities": { "default": [], "type": "array", "items": { - "$ref": "#/components/schemas/BulkCredential" + "$ref": "#/components/schemas/Vulnerability" } - }, - "_rev": { - "type": "string", - "readOnly": true - }, - "id": { - "type": "integer" - }, - "mac": { - "type": "string", - "nullable": true - }, - "service_summaries": { - "readOnly": true } }, "required": [ @@ -5609,37 +5609,43 @@ "BulkCommand": { "type": "object", "properties": { - "hostname": { + "command": { "type": "string", "nullable": true, - "maxLength": 250 + "minLength": 1 + }, + "duration": { + "type": "integer", + "x-unit": "microseconds" + }, + "start_date": { + "type": "string", + "format": "date-time" }, "ip": { "type": "string", "nullable": true, "maxLength": 250 }, - "tool": { + "hostname": { "type": "string", "nullable": true, - "minLength": 1 + "maxLength": 250 }, - "start_date": { + "params": { "type": "string", - "format": "date-time" + "nullable": true }, - "command": { + "user": { "type": "string", "nullable": true, - "minLength": 1 + "maxLength": 250 }, - "params": { + "creator": {}, + "tool": { "type": "string", - "nullable": true - }, - "duration": { - "type": "integer", - "x-unit": "microseconds" + "nullable": true, + "minLength": 1 }, "import_source": { "enum": [ @@ -5649,12 +5655,6 @@ ], "nullable": true, "maxLength": 6 - }, - "creator": {}, - "user": { - "type": "string", - "nullable": true, - "maxLength": 250 } }, "required": [ @@ -5666,9 +5666,6 @@ "BulkCreate": { "type": "object", "properties": { - "execution_id": { - "type": "integer" - }, "hosts": { "type": "array", "items": { @@ -5677,6 +5674,9 @@ }, "command": { "$ref": "#/components/schemas/BulkCommand" + }, + "execution_id": { + "type": "integer" } }, "required": [ @@ -5695,11 +5695,11 @@ "type": "string", "nullable": true }, - "user_query": { + "json_query": { "type": "string", "nullable": true }, - "json_query": { + "user_query": { "type": "string", "nullable": true } diff --git a/faraday/server/api/base.py b/faraday/server/api/base.py index 89bf9799c49..f14f8b059e5 100644 --- a/faraday/server/api/base.py +++ b/faraday/server/api/base.py @@ -1501,7 +1501,7 @@ def bulk_update(self, **kwargs): # Try to get ids if flask.request.json and 'ids' in flask.request.json: - ids = list(filter(lambda x: type(x) == self.lookup_field_type, flask.request.json['ids'])) + ids = list(filter(lambda x: type(x) is self.lookup_field_type, flask.request.json['ids'])) # Try filter if no ids elif flask.request.args.get('q', None) is not None: @@ -1728,7 +1728,7 @@ def bulk_delete(self, **kwargs): # TODO BULK_DELETE_SCHEMA # Try to get ids if flask.request.json and 'ids' in flask.request.json: - ids = list(filter(lambda x: type(x) == self.lookup_field_type, flask.request.json['ids'])) + ids = list(filter(lambda x: type(x) is self.lookup_field_type, flask.request.json['ids'])) # Try filter if no ids elif flask.request.args.get('q', None) is not None: diff --git a/faraday/server/api/modules/hosts.py b/faraday/server/api/modules/hosts.py index 12af57076b5..e98c46ca975 100644 --- a/faraday/server/api/modules/hosts.py +++ b/faraday/server/api/modules/hosts.py @@ -151,11 +151,11 @@ class HostsView(PaginatedMixin, BulkUpdateWorkspacedMixin): route_base = 'hosts' model_class = Host - order_field = desc(Host.vulnerability_critical_generic_count),\ - desc(Host.vulnerability_high_generic_count),\ - desc(Host.vulnerability_medium_generic_count),\ - desc(Host.vulnerability_low_generic_count),\ - desc(Host.vulnerability_info_generic_count),\ + order_field = desc(Host.vulnerability_critical_generic_count), \ + desc(Host.vulnerability_high_generic_count), \ + desc(Host.vulnerability_medium_generic_count), \ + desc(Host.vulnerability_low_generic_count), \ + desc(Host.vulnerability_info_generic_count), \ desc(Host.vulnerability_unclassified_generic_count), Host.ip.asc() schema_class = HostSchema diff --git a/faraday/server/commands/manage_settings.py b/faraday/server/commands/manage_settings.py index c3118f3de0f..16f2d1b6338 100644 --- a/faraday/server/commands/manage_settings.py +++ b/faraday/server/commands/manage_settings.py @@ -52,7 +52,7 @@ def manage(action, json_data, name): for key, value in settings.value.items(): if json_data is not None: json_value = json_data.get(key, None) - if type(json_value) != type(value) or json_value is None: + if type(json_value) is not type(value) or json_value is None: click.secho(f"Missing or Invalid value for {key} [{json_value}]", fg="red") sys.exit(1) else: diff --git a/faraday/server/models.py b/faraday/server/models.py index 0740428277d..49380fc8946 100644 --- a/faraday/server/models.py +++ b/faraday/server/models.py @@ -1917,7 +1917,7 @@ class PolicyViolationVulnerabilityAssociation(db.Model): class ReferenceTemplateVulnerabilityAssociation(db.Model): __tablename__ = 'reference_template_vulnerability_association' - vulnerability_id = Column(Integer, ForeignKey('vulnerability_template.id'), primary_key=True) + vulnerability_id = Column(Integer, ForeignKey('vulnerability_template.id', ondelete='CASCADE'), primary_key=True) reference_id = Column(Integer, ForeignKey('reference_template.id'), primary_key=True) reference = relationship( @@ -1935,7 +1935,7 @@ class ReferenceTemplateVulnerabilityAssociation(db.Model): class PolicyViolationTemplateVulnerabilityAssociation(db.Model): __tablename__ = 'policy_violation_template_vulnerability_association' - vulnerability_id = Column(Integer, ForeignKey('vulnerability_template.id'), primary_key=True) + vulnerability_id = Column(Integer, ForeignKey('vulnerability_template.id', ondelete='CASCADE'), primary_key=True) policy_violation_id = Column(Integer, ForeignKey('policy_violation_template.id'), primary_key=True) policy_violation = relationship("PolicyViolationTemplate", @@ -3206,6 +3206,121 @@ class Analytics(Metadata): show_data_table = Column(Boolean, default=False) +class BaseNotification(Metadata): + __tablename__ = "base_notification" + + id = Column(Integer, primary_key=True) + data = Column(JSONType, nullable=False) + processed = Column(Boolean, default=False) + verbose = Column(Boolean, default=False) + + +class UserNotification(Metadata): + __tablename__ = "user_notification" + + id = Column(Integer, primary_key=True) + message = Column(Text, nullable=False) + extra_data = Column(JSONType, nullable=True) + type = Column(String, nullable=False) + subtype = Column(String, nullable=False) + read = Column(Boolean, default=False) + triggered_by = Column(JSONType) + user_id = Column(Integer, ForeignKey('faraday_user.id'), index=True, nullable=False) + user = relationship('User', + backref=backref('user_notifications', cascade="all, delete-orphan"), + foreign_keys=[user_id]) + links_to = Column(JSONType, nullable=True) + event_date = Column(DateTime, default=datetime.utcnow(), nullable=False) + + def mark_as_read(self): + self.read = True + + def __repr__(self): + return f"{self.message}" + + +class UserNotificationSettings(Metadata): + __tablename__ = 'user_notification_settings' + id = Column(Integer, primary_key=True) + user_id = Column(Integer, ForeignKey('faraday_user.id')) + user = relationship('User', + backref=backref('notification_settings', uselist=False, cascade="all, delete-orphan"), + foreign_keys=[user_id]) + + paused = Column(Boolean, default=False) + slack_id = Column(String, nullable=True, default=None) + no_self_notify = Column(Boolean, default=False) + + agents_enabled = Column(Boolean, default=True) + agents_app = Column(Boolean, default=True) + agents_email = Column(Boolean, default=False) + agents_slack = Column(Boolean, default=False) + + cli_enabled = Column(Boolean, default=True) + cli_app = Column(Boolean, default=True) + cli_email = Column(Boolean, default=False) + cli_slack = Column(Boolean, default=False) + + comments_enabled = Column(Boolean, default=True) + comments_app = Column(Boolean, default=True) + comments_email = Column(Boolean, default=False) + comments_slack = Column(Boolean, default=False) + + hosts_enabled = Column(Boolean, default=True) + hosts_app = Column(Boolean, default=True) + hosts_email = Column(Boolean, default=False) + hosts_slack = Column(Boolean, default=False) + + users_enabled = Column(Boolean, default=True) + users_app = Column(Boolean, default=True) + users_email = Column(Boolean, default=False) + users_slack = Column(Boolean, default=False) + + reports_enabled = Column(Boolean, default=True) + reports_app = Column(Boolean, default=True) + reports_email = Column(Boolean, default=False) + reports_slack = Column(Boolean, default=False) + + vulnerabilities_enabled = Column(Boolean, default=True) + vulnerabilities_app = Column(Boolean, default=True) + vulnerabilities_email = Column(Boolean, default=False) + vulnerabilities_slack = Column(Boolean, default=False) + + workspaces_enabled = Column(Boolean, default=True) + workspaces_app = Column(Boolean, default=True) + workspaces_email = Column(Boolean, default=False) + workspaces_slack = Column(Boolean, default=False) + + pipelines_enabled = Column(Boolean, default=True) + pipelines_app = Column(Boolean, default=True) + pipelines_email = Column(Boolean, default=False) + pipelines_slack = Column(Boolean, default=False) + + executive_reports_enabled = Column(Boolean, default=True) + executive_reports_app = Column(Boolean, default=True) + executive_reports_email = Column(Boolean, default=False) + executive_reports_slack = Column(Boolean, default=False) + + planner_enabled = Column(Boolean, default=True) + planner_app = Column(Boolean, default=True) + planner_email = Column(Boolean, default=False) + planner_slack = Column(Boolean, default=False) + + integrations_enabled = Column(Boolean, default=True) + integrations_app = Column(Boolean, default=True) + integrations_email = Column(Boolean, default=False) + integrations_slack = Column(Boolean, default=False) + + other_enabled = Column(Boolean, default=True) + other_app = Column(Boolean, default=True) + other_email = Column(Boolean, default=False) + other_slack = Column(Boolean, default=False) + + adv_high_crit_vuln = Column(Boolean, default=False) + adv_risk_score_threshold = Column(Integer, default=0) + adv_vuln_open_days = Column(Integer, default=0) + + # Indexes to speed up queries Index("idx_vulnerability_severity_hostid_serviceid", VulnerabilityGeneric.__table__.c.severity, diff --git a/faraday/server/schemas.py b/faraday/server/schemas.py index 2e17b9294a0..b0123a64b69 100644 --- a/faraday/server/schemas.py +++ b/faraday/server/schemas.py @@ -60,8 +60,8 @@ def _serialize(self, value, attr, obj, **kwargs): for custom_field in custom_fields: serialized_value = value.get(custom_field.field_name) - if type(serialized_value) == list: - res[custom_field.field_name] = [element['value'] if type(element) == dict + if type(serialized_value) is list: + res[custom_field.field_name] = [element['value'] if type(element) is dict else element for element in serialized_value] else: res[custom_field.field_name] = serialized_value diff --git a/faraday/server/threads/reports_processor.py b/faraday/server/threads/reports_processor.py index d89ee49a35b..68cca4e33a7 100644 --- a/faraday/server/threads/reports_processor.py +++ b/faraday/server/threads/reports_processor.py @@ -126,7 +126,7 @@ def run(self): tpl: Tuple[str, int, Path, int, int, bool, bool, list, list, list] = \ self.upload_reports_queue.get(False, timeout=0.1) - workspace_name, command_id, file_path, plugin_id, user_id, ignore_info_bool, dns_resolution, vuln_tag,\ + workspace_name, command_id, file_path, plugin_id, user_id, ignore_info_bool, dns_resolution, vuln_tag, \ host_tag, service_tag = tpl logger.info(f"Processing raw report {file_path}") diff --git a/pynixify/packages/faraday-agent-parameters-types/default.nix b/pynixify/packages/faraday-agent-parameters-types/default.nix index 35b74881a52..0521c441c4a 100644 --- a/pynixify/packages/faraday-agent-parameters-types/default.nix +++ b/pynixify/packages/faraday-agent-parameters-types/default.nix @@ -6,12 +6,12 @@ buildPythonPackage rec { pname = "faraday-agent-parameters-types"; - version = "1.3.0"; + version = "1.3.1"; src = fetchPypi { inherit version; pname = "faraday_agent_parameters_types"; - sha256 = "1f6fvnf0lnv02a4fliaf92l6cq8nx7cybna4p74d4pgkqf1rcssx"; + sha256 = "0axhkzcdjx4q9nnlsfjhg3v2v40n2pi22j1z0rv9h3bymwyxjq69"; }; buildInputs = [ pytest-runner ]; diff --git a/pynixify/packages/faraday-plugins/default.nix b/pynixify/packages/faraday-plugins/default.nix index a4faad86d96..8b58ffbe2c3 100644 --- a/pynixify/packages/faraday-plugins/default.nix +++ b/pynixify/packages/faraday-plugins/default.nix @@ -8,11 +8,11 @@ buildPythonPackage rec { pname = "faraday-plugins"; - version = "1.12.1"; + version = "1.13.2"; src = fetchPypi { inherit pname version; - sha256 = "1x3sf5wdipvn0zagws04nxrl08xxwismqyv0bg0k6zyxvj3hxqmc"; + sha256 = "0db1zsmv3lldi41d0av34p130srlyf2njgi33b6a1b3qk79kwgqd"; }; propagatedBuildInputs = [ diff --git a/pynixify/packages/faradaysec/default.nix b/pynixify/packages/faradaysec/default.nix index 99647cf17f5..15c94ba6b15 100644 --- a/pynixify/packages/faradaysec/default.nix +++ b/pynixify/packages/faradaysec/default.nix @@ -16,7 +16,7 @@ buildPythonPackage rec { pname = "faradaysec"; - version = "4.5.0"; + version = "4.6.0"; src = lib.cleanSource ../../..; diff --git a/requirements.txt b/requirements.txt index 4fe7fbd0620..dadc4c1d69f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -36,7 +36,7 @@ syslog-rfc5424-formatter>=1.1.1 simplekv>=0.13.0 Flask-KVSession-fork>=0.6.4 distro>=1.4.0 -faraday-plugins>=1.12.1,<2.0.0 +faraday-plugins>=1.13.2,<2.0.0 apispec>=6.3.0 apispec-webframeworks>=0.5.2 pyyaml diff --git a/tests/test_api_comment.py b/tests/test_api_comment.py index 84ad538a77c..0d2c25db25e 100644 --- a/tests/test_api_comment.py +++ b/tests/test_api_comment.py @@ -91,7 +91,7 @@ def test_create_unique_comment_for_plugins(self, session, test_client): res = test_client.post(url, data=raw_comment) assert res.status_code == 409 assert 'object' in res.json - assert type(res.json) == dict + assert type(res.json) is dict def test_create_unique_comment_for_plugins_after_and_before(self, session, test_client): """ @@ -111,7 +111,7 @@ def test_create_unique_comment_for_plugins_after_and_before(self, session, test_ res = test_client.post(url, data=raw_comment) assert res.status_code == 409 assert 'object' in res.json - assert type(res.json) == dict + assert type(res.json) is dict def test_default_order_field(self, session, test_client): workspace = factories.WorkspaceFactory.create()