erasure on server
This commit is contained in:
parent
69cb07d55a
commit
e900f5f298
|
@ -1,7 +1,9 @@
|
||||||
import copy
|
import copy
|
||||||
import csv
|
import csv
|
||||||
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import uuid
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
@ -1043,7 +1045,7 @@ class ExportsView(View):
|
||||||
|
|
||||||
return self.response_csv(data, "Erasures.csv")
|
return self.response_csv(data, "Erasures.csv")
|
||||||
|
|
||||||
def build_erasure_certificate(self):
|
def get_datastorages(self):
|
||||||
erasures = []
|
erasures = []
|
||||||
for device in self.find_devices():
|
for device in self.find_devices():
|
||||||
if device.placeholder and device.placeholder.binding:
|
if device.placeholder and device.placeholder.binding:
|
||||||
|
@ -1054,11 +1056,66 @@ class ExportsView(View):
|
||||||
elif isinstance(device, DataStorage):
|
elif isinstance(device, DataStorage):
|
||||||
if device.privacy:
|
if device.privacy:
|
||||||
erasures.append(device.privacy)
|
erasures.append(device.privacy)
|
||||||
|
return erasures
|
||||||
|
|
||||||
|
def get_custum_details(self):
|
||||||
|
my_data = None
|
||||||
|
customer_details = None
|
||||||
|
if hasattr(g.user, 'sanitization_entity'):
|
||||||
|
if g.user.sanitization_entity:
|
||||||
|
my_data = list(g.user.sanitization_entity)[0]
|
||||||
|
|
||||||
|
if len(request.referrer.split('/lot/')) > 1:
|
||||||
|
try:
|
||||||
|
lot_id = request.referrer.split('/lot/')[-1].split('/')[0]
|
||||||
|
lot = Lot.query.filter_by(owner=g.user).filter_by(id=lot_id).first()
|
||||||
|
customer_details = lot.transfer.customer_details
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return my_data, customer_details
|
||||||
|
|
||||||
|
def get_server_erasure_hosts(self, erasures):
|
||||||
|
erasures_host = []
|
||||||
|
erasures_on_server = []
|
||||||
|
for erase in erasures:
|
||||||
|
try:
|
||||||
|
if erase.parent.binding.kangaroo:
|
||||||
|
erasures_host.append(erase.parent)
|
||||||
|
erasures_on_server.append(erase)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return erasures_host, erasures_on_server
|
||||||
|
|
||||||
|
def build_erasure_certificate(self):
|
||||||
|
erasures = self.get_datastorages()
|
||||||
|
software = 'USODY DRIVE ERASURE'
|
||||||
|
if erasures and erasures[0].snapshot:
|
||||||
|
software += ' {}'.format(
|
||||||
|
erasures[0].snapshot.version,
|
||||||
|
)
|
||||||
|
|
||||||
|
my_data, customer_details = self.get_custum_details()
|
||||||
|
|
||||||
|
a, b = self.get_server_erasure_hosts(erasures)
|
||||||
|
erasures_host, erasures_on_server = a, b
|
||||||
|
|
||||||
|
result = 'Success'
|
||||||
|
if "Failed" in [e.severity.get_public_name() for e in erasures]:
|
||||||
|
result = 'Failed'
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
'title': 'Erasure Certificate',
|
'title': 'Erasure Certificate',
|
||||||
'erasures': tuple(erasures),
|
'erasures': tuple(erasures),
|
||||||
'url_pdf': '',
|
'url_pdf': '',
|
||||||
|
'date_report': '{:%c}'.format(datetime.datetime.now()),
|
||||||
|
'uuid_report': '{}'.format(uuid.uuid4()),
|
||||||
|
'software': software,
|
||||||
|
'my_data': my_data,
|
||||||
|
'n_computers': len(set([x.parent for x in erasures])),
|
||||||
|
'result': result,
|
||||||
|
'customer_details': customer_details,
|
||||||
|
'erasure_hosts': erasures_host,
|
||||||
|
'erasures_normal': list(set(erasures) - set(erasures_on_server)),
|
||||||
}
|
}
|
||||||
return flask.render_template('inventory/erasure.html', **params)
|
return flask.render_template('inventory/erasure.html', **params)
|
||||||
|
|
||||||
|
|
|
@ -481,6 +481,9 @@ class EraseBasic(JoinedWithOneDeviceMixin, ActionWithOneDevice):
|
||||||
return self.snapshot.device.phid()
|
return self.snapshot.device.phid()
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
def get_public_name(self):
|
||||||
|
return "Basic"
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return '{} on {}.'.format(self.severity, self.date_str)
|
return '{} on {}.'.format(self.severity, self.date_str)
|
||||||
|
|
||||||
|
@ -510,12 +513,33 @@ class EraseSectors(EraseBasic):
|
||||||
|
|
||||||
method = 'Badblocks'
|
method = 'Badblocks'
|
||||||
|
|
||||||
|
def get_public_name(self):
|
||||||
|
# import pdb; pdb.set_trace()
|
||||||
|
steps_random = 0
|
||||||
|
steps_zeros = 0
|
||||||
|
for s in self.steps:
|
||||||
|
if s.type == 'StepRandom':
|
||||||
|
steps_random += 1
|
||||||
|
if s.type == 'StepZero':
|
||||||
|
steps_zeros += 1
|
||||||
|
if steps_zeros < 1:
|
||||||
|
return "Basic"
|
||||||
|
if 0 < steps_random < 3:
|
||||||
|
return "Baseline"
|
||||||
|
if steps_random > 2:
|
||||||
|
return "Enhanced"
|
||||||
|
|
||||||
|
return "Basic"
|
||||||
|
|
||||||
|
|
||||||
class ErasePhysical(EraseBasic):
|
class ErasePhysical(EraseBasic):
|
||||||
"""The act of physically destroying a data storage unit."""
|
"""The act of physically destroying a data storage unit."""
|
||||||
|
|
||||||
method = Column(DBEnum(PhysicalErasureMethod))
|
method = Column(DBEnum(PhysicalErasureMethod))
|
||||||
|
|
||||||
|
def get_public_name(self):
|
||||||
|
return "Physical"
|
||||||
|
|
||||||
|
|
||||||
class Step(db.Model):
|
class Step(db.Model):
|
||||||
erasure_id = Column(
|
erasure_id = Column(
|
||||||
|
|
|
@ -334,6 +334,12 @@ class Severity(IntEnum):
|
||||||
def __format__(self, format_spec):
|
def __format__(self, format_spec):
|
||||||
return str(self)
|
return str(self)
|
||||||
|
|
||||||
|
def get_public_name(self):
|
||||||
|
if self.value == 3:
|
||||||
|
return "Failed"
|
||||||
|
|
||||||
|
return "Success"
|
||||||
|
|
||||||
|
|
||||||
class PhysicalErasureMethod(Enum):
|
class PhysicalErasureMethod(Enum):
|
||||||
"""Methods of physically erasing the data-storage, usually
|
"""Methods of physically erasing the data-storage, usually
|
||||||
|
|
|
@ -68,16 +68,16 @@
|
||||||
<body>
|
<body>
|
||||||
<header class="page-header">
|
<header class="page-header">
|
||||||
<div class="col" style="background-color: #d5a6bd;">
|
<div class="col" style="background-color: #d5a6bd;">
|
||||||
<p style="margin-left: 10px;">2022-12-26 16:51:32 (+0100), USODY DRIVE ERASURE 2022</p>
|
<p style="margin-left: 10px;">{{ date_report }}, {{ software }}</p>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<img class="company-logo" src="https://ksr-ugc.imgix.net/assets/003/488/267/210c162995de80609124abf81047bca7_original.png?ixlib=rb-4.0.2&w=700&fit=max&v=1427136681&auto=format&frame=1&q=92&s=eb4411c5e9d3557ffa64598ac3b238a6" />
|
<img class="company-logo" src="{{ customer_details and customer_details.logo.to_text() or '' }}" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<img class="customer-logo" src="https://e7.pngegg.com/pngimages/243/790/png-clipart-your-company-logo-doing-business-as-company-logo-name-creative-company-logo-free-logo-design-template-text.png" />
|
<img class="customer-logo" src="{{ my_data and my_data.logo.to_text() }}" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -101,7 +101,7 @@
|
||||||
Name:
|
Name:
|
||||||
</td>
|
</td>
|
||||||
<td style="width:80%;">
|
<td style="width:80%;">
|
||||||
ACME
|
<span>{{ ustomer_details and customer_details.company_name or ''}}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr style="padding-top:5px;">
|
<tr style="padding-top:5px;">
|
||||||
|
@ -109,7 +109,7 @@
|
||||||
Location:
|
Location:
|
||||||
</td>
|
</td>
|
||||||
<td style="width:80%;">
|
<td style="width:80%;">
|
||||||
<span>Paseo de Gracia, 2, 08007 Barcelona, España</span>
|
<span>{{ customer_details and customer_details.location or '' }}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -128,7 +128,7 @@
|
||||||
<span>Name:</span>
|
<span>Name:</span>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:80%;">
|
<td style="width:80%;">
|
||||||
<span>Your company</span>
|
<span>{{ my_data and my_data.company_name or '' }}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr style="padding-top:5px;">
|
<tr style="padding-top:5px;">
|
||||||
|
@ -136,7 +136,7 @@
|
||||||
<span>Responsible Person</span>
|
<span>Responsible Person</span>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:80%;">
|
<td style="width:80%;">
|
||||||
<span>John Data</span>
|
<span>{{ my_data and my_data.responsable_person or '' }}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr style="padding-top:5px;">
|
<tr style="padding-top:5px;">
|
||||||
|
@ -144,7 +144,7 @@
|
||||||
<span>Location:</span>
|
<span>Location:</span>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:80%;">
|
<td style="width:80%;">
|
||||||
<span>Madrid, Gran Via 8, 28040 Madrid, España</span>
|
<span>{{ my_data and my_data.location or '' }}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -158,20 +158,35 @@
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<table class="body_content">
|
<table class="body_content">
|
||||||
<tbody>
|
<tbody>
|
||||||
|
{% if erasure_hosts %}
|
||||||
|
{% for e in erasure_hosts %}
|
||||||
|
<tr style="padding-top:5px;">
|
||||||
|
<td style="width:20%;">
|
||||||
|
<span>N° of sanitization server ({{ loop.index }}/{{ erasure_hosts|length }}):</span>
|
||||||
|
</td>
|
||||||
|
<td style="width:80%;">
|
||||||
|
{% if e.serial_number %}
|
||||||
|
<span>{{ e.serial_number.upper() }}</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
<tr style="padding-top:5px;">
|
<tr style="padding-top:5px;">
|
||||||
<td style="width:20%;">
|
<td style="width:20%;">
|
||||||
<span>N° of computers:</span>
|
<span>N° of computers:</span>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:80%;">
|
<td style="width:80%;">
|
||||||
<span>16</span>
|
<span>{{ n_computers }}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{% endif %}
|
||||||
<tr style="padding-top:5px;">
|
<tr style="padding-top:5px;">
|
||||||
<td style="width:20%;">
|
<td style="width:20%;">
|
||||||
<span>N° of data storage unit(s):</span>
|
<span>N° of data storage unit(s):</span>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:80%;">
|
<td style="width:80%;">
|
||||||
<span>16</span>
|
<span>{{ erasures | length }}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr style="padding-top:5px;">
|
<tr style="padding-top:5px;">
|
||||||
|
@ -179,7 +194,7 @@
|
||||||
<span>Sanitization result:</span>
|
<span>Sanitization result:</span>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:80%;">
|
<td style="width:80%;">
|
||||||
<span>Failed</span>
|
<span>{{ result }}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -198,7 +213,7 @@
|
||||||
<span>Report UUID:</span>
|
<span>Report UUID:</span>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:80%;">
|
<td style="width:80%;">
|
||||||
<span>8bcef704-ba04-4320-8056-c8a5c401dbe3</span>
|
<span>{{ uuid_report }}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr style="padding-top:5px;">
|
<tr style="padding-top:5px;">
|
||||||
|
@ -206,7 +221,7 @@
|
||||||
<span>Report Date:</span>
|
<span>Report Date:</span>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:80%;">
|
<td style="width:80%;">
|
||||||
<span>2022-12-26 11:26:24</span>
|
<span>{{ date_report }}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr style="padding-top:5px;">
|
<tr style="padding-top:5px;">
|
||||||
|
@ -214,7 +229,7 @@
|
||||||
<span>Software Version:</span>
|
<span>Software Version:</span>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:80%;">
|
<td style="width:80%;">
|
||||||
<span>Usody Drive Erasure 2022.03.0</span>
|
<span>{{ software }}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -237,15 +252,67 @@
|
||||||
<tr style="padding-top:5px;">
|
<tr style="padding-top:5px;">
|
||||||
<td style="width:50%; text-align: center;">
|
<td style="width:50%; text-align: center;">
|
||||||
<span>Data Responsable</span>
|
<span>Data Responsable</span>
|
||||||
|
<br />
|
||||||
|
<span>{{ my_data and my_data.responsable_person or '' }}</span>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:50%; text-align: center;">
|
<td style="width:50%; text-align: center;">
|
||||||
<span>Data Supervisor</span>
|
<span>Data Supervisor</span>
|
||||||
|
<br />
|
||||||
|
<span>{{ my_data and my_data.supervisor_person or '' }}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if erasures %}
|
||||||
|
{% if erasure_hosts %}
|
||||||
|
{% for server in erasure_hosts %}
|
||||||
|
<div class="row mt-3 page-break">
|
||||||
|
<div class="col">
|
||||||
|
<h1>Server Summary</h1>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<h4>SN Server {{ server.serial_number and server.serial_number.upper() }}</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mt-3">
|
||||||
|
<div class="col">
|
||||||
|
<table class="table" style="width: 100%; text-align: center;">
|
||||||
|
<thead style="border-bottom: 1px solid #000;">
|
||||||
|
<tr>
|
||||||
|
<th scope="col" style="text-align: center;">SN Storage</th>
|
||||||
|
<th scope="col" style="text-align: center;">Method</th>
|
||||||
|
<th scope="col" style="text-align: center;">Result</th>
|
||||||
|
<th scope="col" style="text-align: center;">Date</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for erasure in erasures %}
|
||||||
|
{% if erasure.parent == server %}
|
||||||
|
<tr style="border-bottom: 1px dashed #000;">
|
||||||
|
<td>
|
||||||
|
{{ erasure.device.serial_number.upper() }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ erasure.get_public_name() }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ erasure.severity.get_public_name() }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ erasure.date_str }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% if erasures_normal %}
|
||||||
<div class="row mt-3 page-break">
|
<div class="row mt-3 page-break">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<h1>Devices Summary</h1>
|
<h1>Devices Summary</h1>
|
||||||
|
@ -256,23 +323,23 @@
|
||||||
<table class="table" style="width: 100%; text-align: center;">
|
<table class="table" style="width: 100%; text-align: center;">
|
||||||
<thead style="border-bottom: 1px solid #000;">
|
<thead style="border-bottom: 1px solid #000;">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">SN Storage</th>
|
<th scope="col" style="text-align: center;">SN Storage</th>
|
||||||
<th scope="col">Method</th>
|
<th scope="col" style="text-align: center;">Method</th>
|
||||||
<th scope="col">Result</th>
|
<th scope="col" style="text-align: center;">Result</th>
|
||||||
<th scope="col">Date</th>
|
<th scope="col" style="text-align: center;">Date</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for erasure in erasures %}
|
{% for erasure in erasures_normal %}
|
||||||
<tr style="border-bottom: 1px dashed #000;">
|
<tr style="border-bottom: 1px dashed #000;">
|
||||||
<td>
|
<td>
|
||||||
{{ erasure.device.serial_number.upper() }}
|
{{ erasure.device.serial_number.upper() }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ erasure.type }}
|
{{ erasure.get_public_name() }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ erasure.severity }}
|
{{ erasure.severity.get_public_name() }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ erasure.date_str }}
|
{{ erasure.date_str }}
|
||||||
|
@ -283,10 +350,11 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% for erasure in erasures %}
|
{% for erasure in erasures %}
|
||||||
<div class="container mb-5 page-break">
|
<div class="container mb-5 page-break">
|
||||||
<h4>{{ erasure.device.__format__('t') }}</h4>
|
<h4>{{ erasure.device.serial_number.upper() }}</h4>
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Data storage:</dt>
|
<dt>Data storage:</dt>
|
||||||
<dd>{{ erasure.device.__format__('ts') }}</dd>
|
<dd>{{ erasure.device.__format__('ts') }}</dd>
|
||||||
|
@ -318,5 +386,11 @@
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
<footer class="page-header">
|
||||||
|
<div>
|
||||||
|
<a href="{{ url_for('Document.StampsView', _external=True) }}">Verify on-line the integrity of this document</a>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Reference in New Issue