Skip to content
Open
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
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#

# Create intermediary builder image.
FROM debian:bullseye AS builder
FROM debian:trixie AS builder

# Install build dependencies.
RUN apt-get update && \
Expand All @@ -35,27 +35,27 @@ COPY . /biostools

# Compile bios_extract.
RUN cd /biostools/bios_extract && \
make
make -j `nproc`

# Compile deark.
RUN cd /biostools/deark && \
make
make -j `nproc`

# Create final image.
FROM debian:bullseye
FROM debian:trixie

# Install runtime dependencies.
RUN sed -i -e 's/main/main contrib non-free/' /etc/apt/sources.list && \
RUN sed -i -e 's/Components: main/Components: main contrib non-free/' /etc/apt/sources.list.d/debian.sources &&\
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y python3 python3-pip p7zip-full p7zip-rar innoextract unshield qemu-system-x86 && \
DEBIAN_FRONTEND=noninteractive apt-get install -y python3 python3-pip pip p7zip-full p7zip-rar innoextract unshield qemu-system-i386 && \
apt-get clean && \
rm -rf /var/lib/apt/lists

# Copy repository contents from the intermediary image.
COPY --from=builder /biostools /biostools

# Install Python dependencies.
RUN pip install -r /biostools/requirements.txt
RUN pip install --break-system-packages -r /biostools/requirements.txt

# Establish directories.
VOLUME /bios
Expand Down
12 changes: 6 additions & 6 deletions biostools/analyzers.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def can_analyze(self):
"""Returns True if the given file's strings should be analyzed."""
return len(self._check_list) > 0

def can_handle(self, file_path, file_data, header_data):
def can_handle(self, file_path, file_data, header_data) -> bool:
"""Returns True if this analyzer can handle the given file data.
header_data contains data from the :header: flag file, or
None if no such file exists."""
Expand Down Expand Up @@ -288,7 +288,7 @@ def __init__(self, *args, **kwargs):
super().__init__('AcerMultitech', *args, **kwargs)
self.vendor = 'Acer'

self._version_pattern = re.compile(b'''Multitech Industrial Corp\..BIOS ([^\s]+ [^\s\\x00]+)''')
self._version_pattern = re.compile(br'''Multitech Industrial Corp\..BIOS ([^\s]+ [^\s\\x00]+)''')

def can_handle(self, file_path, file_data, header_data):
# Look for version and date.
Expand Down Expand Up @@ -1671,8 +1671,8 @@ class GeneralSoftwareAnalyzer(Analyzer):
def __init__(self, *args, **kwargs):
super().__init__('General', *args, **kwargs)

self._string_pattern = re.compile(b'''([0-9]{2}/[0-9]{2}/[0-9]{2})\(C\) [0-9]+ General Software, Inc\. ''')
self._version_pattern = re.compile(b'''General Software (?:\\x00 )?([^\\\\\\x0D\\x0A]+)(?:rel\.|Revision)''')
self._string_pattern = re.compile(br'''([0-9]{2}/[0-9]{2}/[0-9]{2})\(C\) [0-9]+ General Software, Inc\. ''')
self._version_pattern = re.compile(br'''General Software (?:\\x00 )?([^\\\\\\x0D\\x0A]+)(?:rel\.|Revision)''')

def can_handle(self, file_path, file_data, header_data):
# Extract version.
Expand Down Expand Up @@ -1994,7 +1994,7 @@ class OlivettiAnalyzer(Analyzer):
def __init__(self, *args, **kwargs):
super().__init__('Olivetti', *args, **kwargs)

self._version_pattern = re.compile('''Version ([^\s]+)''')
self._version_pattern = re.compile(r'''Version ([^\s]+)''')

self.register_check_list([
((self._version_precheck, self._version), AlwaysRunChecker),
Expand Down Expand Up @@ -2029,7 +2029,7 @@ def _version(self, line, match):
return True

def _string_date(self, line, match):
'''^(?:COPYRIGHT \(C\) OLIVETTI )?([0-9]{2}/[0-9]{2}/[0-9]{2})$'''
r'''^(?:COPYRIGHT \(C\) OLIVETTI )?([0-9]{2}/[0-9]{2}/[0-9]{2})$'''

# Extract the date as a string if newer than any previously-found date.
date = match.group(1)
Expand Down
2 changes: 1 addition & 1 deletion biostools/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_url(self, columns):

# Encode the URL.
link_url = link_url.replace('#', '%23')
link_url = re.sub('''\?(^[/]*)/''', '%3F\\1/', link_url)
link_url = re.sub(r'''\?(^[/]*)/''', '%3F\\1/', link_url)

# Stop if the URL is not valid.
slash_index = link_url.find('/')
Expand Down
22 changes: 11 additions & 11 deletions biostools/pciutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@

clean_device_abbr = [
# Generic patterns to catch extended abbreviations: "Abbreviated Terms (AT)"
('([A-Z])[^- ]+[- ]([A-Z])[^ ]+ (?:\(|\[|\{|/)\\2\\3(?:$|\)|\]|\})', '\\2\\3'),
('([A-Z])[^- ]+[- ]([A-Z])[^- ]+[- ]([A-Z])[^ ]+ (?:\(|\[|\{|/)\\2\\3\\4(?:$|\)|\]|\})', '\\2\\3\\4'),
('([A-Z])[^- ]+[- ]([A-Z])[^- ]+[- ]([A-Z])[^- ]+[- ]([A-Z])[^ ]+ (?:\(|\[|\{|/)\\2\\3\\4\\5(?:$|\)|\]|\})', '\\2\\3\\4\\5'),
(r'([A-Z])[^- ]+[- ]([A-Z])[^ ]+ (?:\(|\[|\{|/)\\2\\3(?:$|\)|\]|\})', '\\2\\3'),
(r'([A-Z])[^- ]+[- ]([A-Z])[^- ]+[- ]([A-Z])[^ ]+ (?:\(|\[|\{|/)\\2\\3\\4(?:$|\)|\]|\})', '\\2\\3\\4'),
(r'([A-Z])[^- ]+[- ]([A-Z])[^- ]+[- ]([A-Z])[^- ]+[- ]([A-Z])[^ ]+ (?:\(|\[|\{|/)\\2\\3\\4\\5(?:$|\)|\]|\})', '\\2\\3\\4\\5'),

# Manual patterns
('100Base-TX?', 'FE'),
('1000Base-T', 'GbE'),
('Accelerat(?:ion|or)', 'Accel.'),
('Alert on LAN', 'AoL'),
('\((.+) applications?\)', '(\\2)'), # 8086:105e
(r'\((.+) applications?\)', '(\\2)'), # 8086:105e
('Chipset Family', 'Chipset'),
('Chipset Graphics', 'iGPU'),
('Connection', 'Conn.'),
Expand All @@ -45,7 +45,7 @@
('Host Bus Adapter', 'HBA'),
('Host[- ]Controller', 'HC'), # dash = 1106:3104
('Input/Output', 'I/O'),
('Integrated ([^\s]+) (?:Graphics|GPU)', '\\2 iGPU'), # VIA CLE266
(r'Integrated ([^\s]+) (?:Graphics|GPU)', '\\2 iGPU'), # VIA CLE266
('Integrated (?:Graphics|GPU)', 'iGPU'),
('([0-9]) (lane|port)', '\\2-\\3'),
('Local Area Network', 'LAN'),
Expand All @@ -70,12 +70,12 @@
('Wireless LAN', 'WLAN'),

# Generic pattern to remove duplicate abbreviations: "AT (AT)"
('([^ \(\[\{/]+) (?: |\(|\[|\{|/)\\2(?: |\)|\]|\})', '\\2'),
(r'([^ \(\[\{/]+) (?: |\(|\[|\{|/)\\2(?: |\)|\]|\})', '\\2'),
]
clean_device_bit_pattern = re.compile('''( |^|\(|\[|\{|/)(?:([0-9]{1,4}) )?(?:(K)(?:ilo)?|(M)(?:ega)?|(G)(?:iga)?)bit( |$|\)|\]|\})''', re.I)
clean_device_suffix_pattern = re.compile(''' (?:Adapter|Card|Device|(?:Host )?Controller)( (?: [0-9#]+)?|$|\)|\]|\})''', re.I)
clean_vendor_abbr_pattern = re.compile(''' \[([^\]]+)\]''')
clean_vendor_suffix_pattern = re.compile('''[ ,.](?:Semiconductors?|(?:Micro)?electronics?|Interactive|Technolog(?:y|ies)|(?:Micro)?systems|Computer(?: works)?|Products|Group|and subsidiaries|of(?: America)?|Co(?:rp(?:oration)?|mpany)?|Inc|LLC|Ltd|GmbH(?: & .+)?|AB|AG|SA|(?:\(|\[|\{).*)$''', re.I)
clean_device_bit_pattern = re.compile(r'''( |^|\(|\[|\{|/)(?:([0-9]{1,4}) )?(?:(K)(?:ilo)?|(M)(?:ega)?|(G)(?:iga)?)bit( |$|\)|\]|\})''', re.I)
clean_device_suffix_pattern = re.compile(r''' (?:Adapter|Card|Device|(?:Host )?Controller)( (?: [0-9#]+)?|$|\)|\]|\})''', re.I)
clean_vendor_abbr_pattern = re.compile(r''' \[([^\]]+)\]''')
clean_vendor_suffix_pattern = re.compile(r'''[ ,.](?:Semiconductors?|(?:Micro)?electronics?|Interactive|Technolog(?:y|ies)|(?:Micro)?systems|Computer(?: works)?|Products|Group|and subsidiaries|of(?: America)?|Co(?:rp(?:oration)?|mpany)?|Inc|LLC|Ltd|GmbH(?: & .+)?|AB|AG|SA|(?:\(|\[|\{).*)$''', re.I)
clean_vendor_force = {
'National Semiconductor Corporation': 'NSC',
}
Expand Down Expand Up @@ -108,7 +108,7 @@ def clean_device(device, vendor=None):
if not _clean_device_abbr_cache:
for pattern, replace in clean_device_abbr:
_clean_device_abbr_cache.append((
re.compile('''(?P<prefix> |^|\(|\[|\{|/)''' + pattern + '''(?P<suffix> |$|\)|\]|\})''', re.I),
re.compile(r'''(?P<prefix> |^|\(|\[|\{|/)''' + pattern + r'''(?P<suffix> |$|\)|\]|\})''', re.I),
'\\g<prefix>' + replace + '\\g<suffix>',
))

Expand Down
6 changes: 3 additions & 3 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
# Skip extractor if the 0 directory exists and there's no 1 directory to append.
if [ ! -d /bios/0 -o -d /bios/1 ]
then
# Run extractor.
python3 -u -m biostools -x /bios $* >&2

# Print usage if there's no 1 directory (nothing bound to /bios).
[ ! -d /bios/1 ] && exec python3 -u -m biostools --docker-usage >&2

# Run extractor.
python3 -u -m biostools -x /bios $* >&2

# Fail if there's no 0 directory.
[ ! -d /bios/0 ] && exit 1
fi
Expand Down