Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2568373 rule pack traceability #159

Merged
merged 2 commits into from
Aug 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""rulepack traceability
Revision ID: 70fd7051e03a
Revises: 44ac9602612b
Create Date: 2023-08-15 10:44:17.483160
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '70fd7051e03a'
down_revision = '44ac9602612b'
branch_labels = None
depends_on = None


def upgrade():
op.add_column('rule_pack', sa.Column('created', sa.DateTime(), nullable=False, server_default=sa.func.now()))


def downgrade():
op.drop_column('rule_pack', 'created')
13 changes: 10 additions & 3 deletions components/resc-backend/src/resc_backend/db/model/rule_pack.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Standard Library
from datetime import datetime

# Third Party
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String

# First Party
from resc_backend.db.model import Base
@@ -11,17 +14,21 @@ class DBrulePack(Base):
version = Column("version", String(100), primary_key=True)
global_allow_list = Column(Integer, ForeignKey(DBruleAllowList.id_), nullable=True)
active = Column(Boolean, nullable=False, default=False)
created = Column(DateTime, nullable=False, default=datetime.utcnow)

def __init__(self, version: str, global_allow_list: int = None, active: bool = False):
def __init__(self, version: str, global_allow_list: int = None, active: bool = False,
created: datetime = datetime.utcnow()):
self.version = version
self.global_allow_list = global_allow_list
self.active = active
self.created = created

@staticmethod
def create_from_metadata(version: str, global_allow_list: int, active: bool):
def create_from_metadata(version: str, global_allow_list: int, active: bool, created):
db_rule_pack = DBrulePack(
version=version,
global_allow_list=global_allow_list,
active=active,
created=created
)
return db_rule_pack
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# pylint: disable=no-name-in-module
# Standard Library
import datetime
from typing import Optional

# Third Party
@@ -29,6 +30,7 @@ class RulePack(RulePackBase):

class RulePackRead(RulePackBase):
version: constr(regex=RULE_PACK_VERSION_REGEX)
created: datetime.datetime

class Config:
orm_mode = True
13 changes: 13 additions & 0 deletions components/resc-frontend/src/views/RulePacks.vue
Original file line number Diff line number Diff line change
@@ -86,6 +86,7 @@
<script>
import AxiosConfig from '@/configuration/axios-config.js';
import Config from '@/configuration/config';
import DateUtils from '@/utils/date-utils';
import Spinner from '@/components/Common/Spinner.vue';
import RulePackUploadModal from '@/components/RulePack/RulePackUploadModal.vue';
import Pagination from '@/components/Common/Pagination.vue';
@@ -119,6 +120,14 @@ export default {
class: 'text-left position-sticky',
thStyle: { borderTop: '0px' },
},
{
key: 'created',
sortable: true,
label: 'Created',
class: 'text-left position-sticky',
thStyle: { borderTop: '0px' },
formatter: 'formatDate',
},
{
key: 'download',
sortable: false,
@@ -182,6 +191,10 @@ export default {
AxiosConfig.handleError(error);
});
},
formatDate(timestamp) {
const date = DateUtils.formatDate(timestamp);
return timestamp ? date : 'Not Scanned';
},
},
created() {