Merge pull request #383 from eReuse/changes/3861-setup

Changes/3861 setup
This commit is contained in:
cayop 2022-10-17 18:48:14 +02:00 committed by GitHub
commit 00e40cbdeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 188 additions and 81 deletions

View File

@ -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()}')

View File

@ -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"""

View File

@ -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():

View File

@ -68,7 +68,7 @@
</div>
<div class="row">
<div class="col-xl-6">
<div class="col">
<div class="card">
<div class="card-body">
@ -82,120 +82,150 @@
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-8">
</div>
</div>
{% if demo %}
<div class="row">
<div class="col-xl-6">
<div class="col">
<div class="card">
<div class="card-body">
<div class="pt-6 pb-2">
<h5 class="card-title text-center pb-0 fs-4">Workbench 2022</h5>
<div class="row pt-3">
<div class="col-5">
<a href="{{ iso.demo.url }}{{ iso.demo.iso }}" class="btn btn-primary">{{ iso.demo.iso }}</a>
<h5 class="card-title pb-0 fs-4">Usody Metadata Snapshots</h5>
<p class="mb-5">
A certified collection of hardware details and testing reports<br />
<small>Desktops, Servers and Laptops</small>
</p>
<div class="row">
<div class="col-2">
<a href="{{ iso_register.url }}{{ iso_register.iso }}" class="btn btn-primary" style="max-width: 200px;">
Download ISO
</a>
</div>
<div class="col">
<div class="col-3">
<p class="small">
Download Checksum: <a class="help" href="{{ iso.demo.url }}SHA512SUM">SHA512SUM</a> |
<a href="https://help.usody.com/es/setup/setup-pendrive/" target="_blank" class="help">Help</a></p>
Download Checksum: <a class="help" href="{{ iso_register.url }}SHA512SUM">SHA512SUM</a> |
<a href="https://help.usody.com/es/setup/setup-pendrive/" target="_blank" class="help">Help</a>
</p>
</div>
<div class="col"></div>
</div>
<div class="row mt-3">
<div class="col-3">
<div class="border mr-2 p-2">
<h5>Basic Metadata</h5>
<p>Settings for basic hardware metadata collection and hard drive smart Test reports.</p>
<a href="{{ url_for('workbench.settings') }}?opt=register" class="btn btn-primary" style="width: 100%">Download settings file</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-8">
</div>
</div>
{% else %}
{% for d, v in iso.items() %}
{% if d != 'demo' %}
{% if not demo %}
<div class="row">
<div class="col-xl-6">
<div class="col">
<div class="card">
<div class="card-body">
<div class="pt-6 pb-2">
<h5 class="card-title text-center pb-0 fs-4">Workbench {{ d }}</h5>
{% if d == 'v14' %}
<div class="pt-8 pb-2">
<h5 class="card-title pb-0 fs-4">Usody Erasure Snapshots</h5>
<p class="mb-5">
A certified data erasure software to irreversibly removing data sored on hard drives.<br />
<small>Desktops, Servers and Laptops</small>
</p>
<div class="row">
<div class="col-5">
<a href="{{ url_for('workbench.settings') }}?opt=erease_basic" class="btn btn-primary" style="width: 200px;">Get settings file!</a>
<div class="col-2">
<a href="{{ iso_erease.url }}{{ iso_erease.iso }}" class="btn btn-primary" style="max-width: 200px;">
Download ISO
</a>
</div>
<div class="col">
<div class="col-3">
<p class="small">
Settings for basic data erasure. | <a href="https://help.usody.com/es/setup/setup-pendrive/" target="_blank" class="help">Help</a>
Download Checksum: <a class="help" href="{{ iso_erease.url }}SHA512SUM">SHA512SUM</a> |
<a href="https://help.usody.com/es/setup/setup-pendrive/" target="_blank" class="help">Help</a>
</p>
</div>
<div class="col"></div>
</div>
<div class="row mt-3">
<div class="col-3">
<div class="border mr-2 p-2">
<h5>Basic Erasure</h5>
<p>
Settings for basic data erasure using shred Linux command.
A software-based fast non-100%-secured way of erasing data storage.
</p>
<p>
Performs <strong>1</strong> pass overwriting one round using all zeros.
Compliant with <strong>NIST SP-800-88</strong>
</p>
<a href="{{ url_for('workbench.settings') }}?opt=erease_basic"
class="btn btn-primary"
style="width: 100%;">
Download settings file
</a>
</div>
</div>
<div class="col-3">
<div class="border mr-2 p-2">
<h5>Baseline Secure Erasure</h5>
<p>
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.
</p>
<p>
Performs <strong>1</strong> pass overwriting each sector with zeros and a final verification.
Compliant with <strong>HMG Infosec Standard 5 Baseline</strong>.
</p>
<a href="{{ url_for('workbench.settings') }}?opt=erease_sectors"
class="btn btn-primary"
style="width: 100%;">
Download settings file
</a>
</div>
</div>
<div class="col-3">
<div class="border mr-2 p-2">
<h5>Enhanced Secure Erasure</h5>
<p>
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.
</p>
<p>
Performs <strong>3</strong> passes overwriting every sector with zeros and ones, and final verification.
Compliant with <strong>HMG Infosec Standard 5 Enhanced</strong>.
</p>
<span
class="btn btn-secondary"
style="width: 100%;">
Download settings file
</span>
</div>
</div>
</div>
<div class="row pt-2">
<div class="col-5">
<a href="{{ url_for('workbench.settings') }}?opt=erease_sectors" class="btn btn-primary" style="width: 200px;">Get settings file!</a>
</div>
<div class="col">
<p class="small">
Settings for advanced data erasure through sectors and hidden areas. Guarantee of data removal. | <a href="https://help.usody.com/es/setup/setup-pendrive/" target="_blank" class="help">Help</a>
</p>
</div>
</div>
{% else %}
<div class="row">
<div class="col-5">
<a href="{{ url_for('workbench.settings') }}?opt=register" class="btn btn-primary" style="width: 200px;">Get settings file!</a>
</div>
<div class="col">
<p class="small">
Settings for register devices.
</p>
</div>
</div>
{% endif %}
{% if iso %}
<br />
<div class="row">
<div class="col-5">
<a href="{{ v.url }}{{ v.iso }}" class="btn btn-primary" style="width: 200px;">Get ISO file</a>
</div>
<div class="col">
<p class="small">
{{ v.iso }}
</p>
<p class="small">
Download Checksum: <a class="help" href="{{ v.url }}SHA512SUM">SHA512SUM</a> |
<a href="https://help.usody.com/es/setup/setup-pendrive/" target="_blank" class="help">Help</a></p>
</p>
</div>
</div>
{% endif %}
</div>
</div>
</div>
</div>
<div class="col-xl-8">
</div>
</div>
{% endif %}
{% endfor %}
{% endif %}
</section>
{% endblock main %}

View File

@ -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/',
},

View File

@ -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,
}
)

View File

@ -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