diff --git a/ereuse_devicehub/migrations/versions/d65745749e34_add_is_server_erase.py b/ereuse_devicehub/migrations/versions/d65745749e34_add_is_server_erase.py new file mode 100644 index 00000000..20d001db --- /dev/null +++ b/ereuse_devicehub/migrations/versions/d65745749e34_add_is_server_erase.py @@ -0,0 +1,34 @@ +"""add is_server_erase + +Revision ID: d65745749e34 +Revises: a13ed6ad0e3e +Create Date: 2022-10-17 13:20:29.875274 + +""" +import sqlalchemy as sa +from alembic import context, op + +# revision identifiers, used by Alembic. +revision = 'd65745749e34' +down_revision = 'a13ed6ad0e3e' +branch_labels = None +depends_on = None + + +def get_inv(): + INV = context.get_x_argument(as_dictionary=True).get('inventory') + if not INV: + raise ValueError("Inventory value is not specified") + return INV + + +def upgrade(): + op.add_column( + 'snapshot', + sa.Column('is_server_erase', sa.Boolean(), nullable=True), + schema=f'{get_inv()}', + ) + + +def downgrade(): + op.drop_column('snapshot', 'is_server_erase', schema=f'{get_inv()}') diff --git a/ereuse_devicehub/resources/action/models.py b/ereuse_devicehub/resources/action/models.py index 496eed34..87a9d392 100644 --- a/ereuse_devicehub/resources/action/models.py +++ b/ereuse_devicehub/resources/action/models.py @@ -676,6 +676,7 @@ class Snapshot(JoinedWithOneDeviceMixin, ActionWithOneDevice): of time it took to complete. """ sid = Column(CIText(), nullable=True) + is_server_erase = Column(Boolean(), nullable=True) def get_last_lifetimes(self): """We get the lifetime and serial_number of the first disk""" diff --git a/ereuse_devicehub/resources/action/views/snapshot.py b/ereuse_devicehub/resources/action/views/snapshot.py index bca48f84..dd967fee 100644 --- a/ereuse_devicehub/resources/action/views/snapshot.py +++ b/ereuse_devicehub/resources/action/views/snapshot.py @@ -115,8 +115,15 @@ class SnapshotMixin: if snapshot.device.hid is None: snapshot.severity = Severity.Warning + self.is_server_erase(snapshot) + return snapshot + def is_server_erase(self, snapshot): + if snapshot.device.binding: + if snapshot.device.binding.kangaroo: + snapshot.is_server_erase = True + def get_old_smbios_version(self, debug): capabilities = debug.get('lshw', {}).get('capabilities', {}) for x in capabilities.values(): diff --git a/ereuse_devicehub/templates/workbench/settings.html b/ereuse_devicehub/templates/workbench/settings.html index f1644d3e..1a051e76 100644 --- a/ereuse_devicehub/templates/workbench/settings.html +++ b/ereuse_devicehub/templates/workbench/settings.html @@ -68,7 +68,7 @@
-
+
@@ -82,120 +82,150 @@
-
+
-
-
- - {% if demo %}
-
+
-
Workbench 2022
-
-
- {{ iso.demo.iso }} +
Usody Metadata Snapshots
+

+ A certified collection of hardware details and testing reports
+ Desktops, Servers and Laptops +

+ +
+ -
+

- Download Checksum: SHA512SUM | - Help

+ Download Checksum: SHA512SUM | + Help

+
+ +
+
+
+
Basic Metadata
+

Settings for basic hardware metadata collection and hard drive smart Test reports.

+ Download settings file +
+
+
+
-
-
-
- - {% else %} - {% for d, v in iso.items() %} - {% if d != 'demo' %} + {% if not demo %}
-
- +
-
-
Workbench {{ d }}
- {% if d == 'v14' %} +
+
Usody Erasure Snapshots
+

+ A certified data erasure software to irreversibly removing data sored on hard drives.
+ Desktops, Servers and Laptops +

+
-
- Get settings file! + -
+

- Settings for basic data erasure. | Help + Download Checksum: SHA512SUM | + Help

+
+
+ +
+
+
+
Basic Erasure
+

+ Settings for basic data erasure using shred Linux command. + A software-based fast non-100%-secured way of erasing data storage. +

+

+ Performs 1 pass overwriting one round using all zeros. + Compliant with NIST SP-800-88 +

+ + Download settings file + +
+
+ +
+
+
Baseline Secure Erasure
+

+ Settings for advanced data erasure using badblocks Linux software. + A secured-way of erasing data storages, erase hidden areas, checking the erase sector by sector. +

+

+ Performs 1 pass overwriting each sector with zeros and a final verification. + Compliant with HMG Infosec Standard 5 Baseline. +

+ + Download settings file + +
+
+ +
+
+
Enhanced Secure Erasure
+

+ Settings for advanced data erasure using badblocks Linux software. + A secured-way of erasing data storages, erase hidden areas, checking the erase sector by sector. +

+

+ Performs 3 passes overwriting every sector with zeros and ones, and final verification. + Compliant with HMG Infosec Standard 5 Enhanced. +

+ + Download settings file + +
+
-
- -
-

- Settings for advanced data erasure through sectors and hidden areas. Guarantee of data removal. | Help -

-
-
- {% else %} -
- -
-

- Settings for register devices. -

-
-
- {% endif %} - {% if iso %} -
-
- -
-

- {{ v.iso }} -

-

- Download Checksum: SHA512SUM | - Help

-

-
-
- {% endif %} +
+
-
- -
-
{% endif %} - {% endfor %} - - {% endif %} - {% endblock main %} diff --git a/ereuse_devicehub/workbench/__init__.py b/ereuse_devicehub/workbench/__init__.py index bf0e2926..bd4530a4 100644 --- a/ereuse_devicehub/workbench/__init__.py +++ b/ereuse_devicehub/workbench/__init__.py @@ -3,11 +3,11 @@ isos = { 'iso': "USODY_2022.8.0-Demo.iso", 'url': 'http://releases.usody.com/demo/', }, - "2022": { + "register": { 'iso': "USODY_2022.8.0-beta.iso", 'url': 'http://releases.usody.com/2022/', }, - "v14": { + "erease": { 'iso': "USODY_14.0.0.iso", 'url': 'http://releases.usody.com/v14/', }, diff --git a/ereuse_devicehub/workbench/views.py b/ereuse_devicehub/workbench/views.py index 60c34fd3..28842826 100644 --- a/ereuse_devicehub/workbench/views.py +++ b/ereuse_devicehub/workbench/views.py @@ -23,7 +23,7 @@ class SettingsView(GenericMixin): decorators = [login_required] methods = ['GET', 'POST'] template_name = 'workbench/settings.html' - page_title = "Workbench" + page_title = "Snapshots" def dispatch_request(self): self.get_context() @@ -32,7 +32,9 @@ class SettingsView(GenericMixin): { 'page_title': self.page_title, 'demo': g.user.email == app.config['EMAIL_DEMO'], - 'iso': isos, + 'iso_demo': isos['demo'], + 'iso_register': isos['register'], + 'iso_erease': isos['erease'], 'form': form_kangaroo, } ) diff --git a/tests/test_render_2_0.py b/tests/test_render_2_0.py index 2dcd7100..dbe3c851 100644 --- a/tests/test_render_2_0.py +++ b/tests/test_render_2_0.py @@ -2534,3 +2534,36 @@ def test_filter_hdd_in_kangaroo(user3: UserClientFlask): assert status == '200 OK' for hdd in Device.query.filter_by(type='HardDrive').all(): assert hdd.dhid in body + + +@pytest.mark.mvp +@pytest.mark.usefixtures(conftest.app_context.__name__) +def test_snapshot_is_server_erase(user3: UserClientFlask): + snapshot = create_device(user3, 'real-eee-1001pxd.snapshot.12.json') + + user3.get('/workbench/') + data = { + 'csrf_token': generate_csrf(), + 'phid': snapshot.device.phid(), + } + user3.post('/workbench/', data=data) + + uri = '/inventory/upload-snapshot/' + file_name = 'real-eee-1001pxd.snapshot.12' + snapshot_json = conftest.yaml2json(file_name) + snapshot_json['uuid'] = 'c058e8d2-fb92-47cb-a4b7-522b75561136' + b_snapshot = bytes(json.dumps(snapshot_json), 'utf-8') + file_snap = (BytesIO(b_snapshot), file_name) + user3.get(uri) + + data = { + 'snapshot': file_snap, + 'csrf_token': generate_csrf(), + } + user3.post(uri, data=data, content_type="multipart/form-data") + snapshot2 = Snapshot.query.filter_by(uuid=snapshot_json['uuid']).one() + + assert not snapshot.is_server_erase + assert snapshot2.is_server_erase + assert snapshot in snapshot.device.actions + assert snapshot2 in snapshot.device.actions