forked from SK-CERT/Taranis-NG
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fix broken AFFECTED SYSTEMS field (affected by later update) - add suport for multiline in DESCRIPTION, AFFECTED SYSTEMS & RECOMMENDATIONS fields
- Loading branch information
Jan Polonsky
committed
Feb 2, 2024
1 parent
f48f021
commit 82915ee
Showing
3 changed files
with
75 additions
and
13 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
src/core/migrations/versions/dfc12c30395b_Affected_systems.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
"""Affected systems to text area | ||
Revision ID: dfc12c30395b | ||
Revises: e87b34c74db0 | ||
Create Date: 2024-01-31 13:35:10.639848 | ||
""" | ||
from alembic import op | ||
from datetime import datetime | ||
from sqlalchemy import orm, Column, ForeignKey, String, Integer, DateTime, Boolean, Enum, text | ||
from sqlalchemy.ext.declarative import declarative_base | ||
import sqlalchemy as sa | ||
|
||
Base = declarative_base() | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'dfc12c30395b' | ||
down_revision = 'e87b34c74db0' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
class ReportItemType_dfc12c30395b(Base): | ||
__tablename__ = 'report_item_type' | ||
id = Column(Integer, primary_key=True, server_default=text("nextval('report_item_type_id_seq'::regclass)")) | ||
title = Column(String) | ||
|
||
class AttributeGroup_dfc12c30395b(Base): | ||
__tablename__ = 'attribute_group' | ||
id = Column(Integer, primary_key=True, server_default=text("nextval('attribute_group_id_seq'::regclass)")) | ||
title = Column(String) | ||
report_item_type_id = Column(ForeignKey('report_item_type.id')) | ||
|
||
class AttributeGroupItem_dfc12c30395b(Base): | ||
__tablename__ = 'attribute_group_item' | ||
id = Column(Integer, primary_key=True, server_default=text("nextval('attribute_group_item_id_seq'::regclass)")) | ||
title = Column(String) | ||
attribute_group_id = Column(ForeignKey('attribute_group.id')) | ||
attribute_id = Column(ForeignKey('attribute.id')) | ||
|
||
class Attribute_dfc12c30395b(Base): | ||
__tablename__ = 'attribute' | ||
id = Column(Integer, primary_key=True, server_default=text("nextval('attribute_id_seq'::regclass)")) | ||
name = Column(String, nullable=False) | ||
|
||
def upgrade(): | ||
bind = op.get_bind() | ||
session = orm.Session(bind=bind) | ||
|
||
# ======= Update existing old report ======= | ||
rit = session.query(ReportItemType_dfc12c30395b).filter_by(title = 'Vulnerability Report').first() | ||
if rit: | ||
ag = session.query(AttributeGroup_dfc12c30395b).filter_by(title = 'Identify and Act', report_item_type_id = rit.id).first() | ||
if ag: | ||
atr_text_id = session.query(Attribute_dfc12c30395b).filter_by(name = 'Text').first().id | ||
agi = session.query(AttributeGroupItem_dfc12c30395b).filter_by(title = 'Affected systems', attribute_group_id = ag.id, attribute_id = atr_text_id).first() | ||
if agi: | ||
atr_text_area_id = session.query(Attribute_dfc12c30395b).filter_by(name = 'Text Area').first().id | ||
agi.attribute_id = atr_text_area_id | ||
session.add(agi) | ||
session.commit() | ||
else: | ||
print("Nothing to upgrade...", flush=True) | ||
else: | ||
print("No report attribute group to upgrade...", flush=True) | ||
else: | ||
print("No report to upgrade...", flush=True) | ||
|
||
def downgrade(): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters