Made requested changes
This commit is contained in:
parent
f0fa7032c1
commit
66822781d9
|
@ -164,7 +164,7 @@ class AliasGeneratorEnum(EnumE):
|
|||
|
||||
class HibpDataClass(db.Model, ModelMixin):
|
||||
__tablename__ = "hibpdataclass"
|
||||
description = db.Column(db.Text, nullable=False, unique=True, index=True)
|
||||
attribute = db.Column(db.Text, nullable=False, unique=True, index=True)
|
||||
|
||||
breaches = db.relationship("Hibp", secondary="hibp_hibpdataclass")
|
||||
|
||||
|
@ -2089,7 +2089,7 @@ class HibpHibpDataClass(db.Model, ModelMixin):
|
|||
),
|
||||
)
|
||||
|
||||
hibp_id = db.Column(db.Integer(), db.ForeignKey("hibp.id"))
|
||||
hibp_id = db.Column(db.Integer(), db.ForeignKey("hibp.id"), index=True)
|
||||
hibp_dataclass_id = db.Column(db.Integer(), db.ForeignKey("hibpdataclass.id"))
|
||||
|
||||
hibp = db.relationship(
|
||||
|
|
6
cron.py
6
cron.py
|
@ -842,7 +842,7 @@ async def check_hibp():
|
|||
LOG.d("Updating list of known breach types")
|
||||
r = requests.get("https://haveibeenpwned.com/api/v3/dataclasses")
|
||||
for entry in r.json():
|
||||
HibpDataClass.get_or_create(description=entry)
|
||||
HibpDataClass.get_or_create(attribute=entry)
|
||||
|
||||
db.session.commit()
|
||||
|
||||
|
@ -853,8 +853,8 @@ async def check_hibp():
|
|||
hibp_entry.date = arrow.get(entry["BreachDate"])
|
||||
hibp_entry.description = entry["Description"]
|
||||
hibp_entry.data_classes = [
|
||||
HibpDataClass.get_by(description=description)
|
||||
for description in entry["DataClasses"]
|
||||
HibpDataClass.get_by(attribute=attribute)
|
||||
for attribute in entry["DataClasses"]
|
||||
]
|
||||
|
||||
db.session.commit()
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
"""empty message
|
||||
|
||||
Revision ID: 618614d64d1c
|
||||
Revision ID: 4d501f682763
|
||||
Revises: 6cc7f073b358
|
||||
Create Date: 2021-05-24 19:44:26.161445
|
||||
Create Date: 2021-06-01 19:30:15.904980
|
||||
|
||||
"""
|
||||
import sqlalchemy_utils
|
||||
|
@ -11,7 +11,7 @@ import sqlalchemy as sa
|
|||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '618614d64d1c'
|
||||
revision = '4d501f682763'
|
||||
down_revision = '6cc7f073b358'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
@ -23,10 +23,10 @@ def upgrade():
|
|||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('created_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
|
||||
sa.Column('updated_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=True),
|
||||
sa.Column('description', sa.Text(), nullable=False),
|
||||
sa.Column('attribute', sa.Text(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_hibpdataclass_description'), 'hibpdataclass', ['description'], unique=True)
|
||||
op.create_index(op.f('ix_hibpdataclass_attribute'), 'hibpdataclass', ['attribute'], unique=True)
|
||||
op.create_table('hibp_hibpdataclass',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('created_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
|
||||
|
@ -38,6 +38,7 @@ def upgrade():
|
|||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('hibp_id', 'hibp_dataclass_id', name='uq_hibp_hibpdataclass')
|
||||
)
|
||||
op.create_index(op.f('ix_hibp_hibpdataclass_hibp_id'), 'hibp_hibpdataclass', ['hibp_id'], unique=False)
|
||||
op.add_column('hibp', sa.Column('date', sqlalchemy_utils.types.arrow.ArrowType(), nullable=True))
|
||||
op.add_column('hibp', sa.Column('description', sa.Text(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
@ -47,7 +48,8 @@ def downgrade():
|
|||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('hibp', 'description')
|
||||
op.drop_column('hibp', 'date')
|
||||
op.drop_index(op.f('ix_hibp_hibpdataclass_hibp_id'), table_name='hibp_hibpdataclass')
|
||||
op.drop_table('hibp_hibpdataclass')
|
||||
op.drop_index(op.f('ix_hibpdataclass_description'), table_name='hibpdataclass')
|
||||
op.drop_index(op.f('ix_hibpdataclass_attribute'), table_name='hibpdataclass')
|
||||
op.drop_table('hibpdataclass')
|
||||
# ### end Alembic commands ###
|
|
@ -18,7 +18,7 @@
|
|||
{{ render_text(breach.name + " (" + breach.date.format('YYYY-MM-DD') + ")") }}
|
||||
{{ render_text(breach.description) }}
|
||||
|
||||
{{ render_text("Breached data: " + breach.data_classes|join(', ', attribute='description')) }}
|
||||
{{ render_text("Breached data: " + breach.data_classes|join(', ', attribute='attribute')) }}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
{%- endif %}
|
||||
|
|
|
@ -18,7 +18,7 @@ And {{ (alias.hibp_breaches_not_notified_user|length) - 3 }} more data breaches.
|
|||
{{ breach.name }} ({{ breach.date.format('YYYY-MM-DD') }})
|
||||
{{ breach.description|striptags }}
|
||||
|
||||
Breached data: {{ breach.data_classes|join(', ', attribute='description') }}
|
||||
Breached data: {{ breach.data_classes|join(', ', attribute='attribute') }}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
{%- endif %}
|
||||
|
|
Loading…
Reference in New Issue