Skip to content
Draft
Show file tree
Hide file tree
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
23 changes: 0 additions & 23 deletions Makefile

This file was deleted.

12 changes: 2 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,10 @@ to generate detailed code documentation automatically.
To generate the documentation run the following:

```bash
(venv) make html
python -m http.server 8000
(venv) mkdocs serve
```

For live preview run:

```bash
(venv) make livehtml
```

Open the web browser and type `localhost:8000` as address. Or alternatively
open `build/html/index.html` file in the web browser directly.
Open the web browser and type `localhost:8000` as address.

## Checking Python style

Expand Down
5 changes: 5 additions & 0 deletions docs/coreboot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
::: openness_score.coreboot
handler: python
options:
filters: []
docstring_style: numpy
28 changes: 12 additions & 16 deletions docs/source/design.rst → docs/design.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
Dasharo Openness Score design
=============================
# Dasharo Openness Score design

Dasharo Openness Score is designed following a few patterns and design rules.


Dasharo Openness Score general rules
------------------------------------
## Dasharo Openness Score general rules

1. The utility should not leave any intermediate files during the firmware
image processing.
Expand All @@ -23,29 +20,28 @@ Dasharo Openness Score general rules

3. The utility must be sa precise as possible to avoid falsified results.

Dasharo Openness Score module design rules
------------------------------------------
## Dasharo Openness Score module design rules

Each class representing a firmware image (or its integral part):

1. Must calculate the 4 basic metrics (empty, data, closed-source and
open-source) on the class instance creation.
2. Should have a string method ``__str__`` which returns a set of 4 basic
2. Should have a string method `__str__` which returns a set of 4 basic
metrics and general attributes of the entity
3. Should have a length method ``__len__`` which returns the size of the
3. Should have a length method `__len__` which returns the size of the
firmware image (or its integral part)
4. Must contain attributes for the basic metrics using the following names:
``self.open_code_size``, ``self.closed_code_size``, ``self.data_size`` and
``self.empty_size``
5. Must implement ``export_markdown`` method that will produce a markdown
`self.open_code_size`, `self.closed_code_size`, `self.data_size` and
`self.empty_size`
5. Must implement `export_markdown` method that will produce a markdown
report of the firmware image (or its integral part) statistics
6. Must implement ``_calculate_metrics`` method which will perform the image
6. Must implement `_calculate_metrics` method which will perform the image
component classification and do the calculations
7. Should implement a parse method which will perform the extraction of the
image components and its attributes
8. Must call the parse method and ``_calculate_metrics`` inside the class'
``__init__`` method
9. Must implement ``export_charts`` method to generate pie charts (only for
8. Must call the parse method and `_calculate_metrics` inside the class'
`__init__` method
9. Must implement `export_charts` method to generate pie charts (only for
classes representing the whole firmware image)
10. Must assume a component as closed-source if unable to classify to any
category.
133 changes: 133 additions & 0 deletions docs/extra.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/* Style for class containers */
div.doc-class {
background-color: #f8fbff;
border-left: 4px solid #4a90e2; /* blue left border */
margin-bottom: 1em;
padding-left: 10px;
}

/* Class name styling */
div.doc-class > .doc-object-name {
font-weight: bold;
font-size: 1.2em;
color: #2c3e50; /* dark blue */
}

/* Method/function container */
div.doc-method, div.doc-function {
background-color: #fafaff;
border-bottom: 1px dashed #d0d7de;
border-left: 2px solid #888888; /* gray left border */
margin-bottom: 0.8em;
margin-left: 20px;
padding-bottom: 4px;
padding-left: 10px;
}

/* Method/function name */
div.doc-method > .doc-object-name,
div.doc-function > .doc-object-name {
font-weight: bold;
color: #e67e22; /* orange */
font-style: normal;
}

/* Function/method signature arguments */
div.doc-method span.signature {
font-style: italic;
color: #7f8c8d; /* grayish */
}

/* Parameter names inside signature */
div.doc-method span.signature > .param {
font-weight: normal;
font-style: italic;
color: #16a085; /* teal */
}

/* Return type or annotation styling */
div.doc-method span.annotation {
color: #2980b9; /* blue */
font-weight: normal;
}

/* Attribute blocks */
div.doc-attribute {
margin-left: 20px;
color: #34495e; /* dark gray-blue */
font-style: normal;
}

/* Highlight decorators if present */
div.doc-decorator {
color: #8e44ad; /* purple */
font-weight: bold;
}

/* Headings */
h5.doc-heading {
font-weight: 700;
color: #34495e;
margin-top: 1em;
}

/* Don't render the Python lists' elements */
div.doc-signature {
display: none;
}

/* Don't render doc-label */
small.doc-label {
display: none;
}

/* Don't render doc-symbol-heading */
code.doc-symbol-heading {
display: none;
}

/* Table header styling */
th {
background-color: #f2f4f8; /* Soft cool background */
color: #2c3e50; /* Dark navy text for readability */
font-weight: 600; /* Slightly bolder */
text-align: left; /* Align headers to the left */
padding: 0.6em 1em; /* Comfortable padding */
border-bottom: 2px solid #a9bcd0; /* Distinct bottom border */
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Table row styling */
tr {
vertical-align: middle;
border-bottom: 1px solid #e1e4ea; /* Subtle row separator */
}

/* Alternate row shading */
tr:nth-child(even) {
background-color: #fcfdfe; /* Very light grey for even rows */
}

/* On hover highlight for rows */
tr:hover {
background-color: #e9f0fb; /* Light blue highlight */
transition: background-color 0.3s ease;
}

/* Cell padding for data cells */
td {
padding: 0.5em 1em;
font-family: 'Consolas', 'Courier New', monospace; /* Monospaced for code readability */
color: #3a3a3a;
}

/* For extra.js */
a.reference-link {
font-family: monospace;
background-color: #f5f5f5;
border: 1px solid #ccc;
border-radius: 3px;
padding: 0.1em 0.3em;
text-decoration: none;
color: inherit;
}
11 changes: 11 additions & 0 deletions docs/extra.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
document.addEventListener("DOMContentLoaded", () => {
const container = document.querySelector('div.wy-nav-content');
if (!container) return;

container.querySelectorAll('a').forEach(link => {
const href = link.getAttribute('href') || '';
if (href.startsWith('../')) {
link.classList.add('reference-link');
}
});
});
32 changes: 32 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Dasharo Openness Score

## What is Dasharo Openness Score

Have you ever wondered how open is your open-source firmware? How much
closed-source and binary blobs is still there? Dasharo Openness Score utility
answers those questions.

Dasharo Openness is a report showing the open-source code to closed-source
code ratio in the Dasharo firmware images. The results are also presented as a
pie chart for better visual representation of the firmware image components
and their share percentage.

Dasharo Openness Score utility is capable of parsing Dasharo coreboot-based
images as well as vendor UEFI images. Thanks to that one can easily compare
how many bytes of the firmware have been liberated as well as by how much the
Trusted Computing Base (TCB) has been reduced.

Dasharo Openness Score utility not only support Dasharo coreboot-based images,
but also many more coreboot distributions like heads.

## How does it work?

The utility leverages various tools like [coreboot's cbfstool][cbfstool] or
[LongSoft's UEFIExtract][uefiextract] to decompose and parse the firmware
images. The output from the utilities is used to detect the image type and then
to calculate the openness metrics.

For more details please refer to the [methodology document](./methodology.md)

[cbfstool]: https://github.com/coreboot/coreboot/tree/master/util/cbfstool
[uefiextract]: https://github.com/LongSoft/UEFITool
Loading