Kernel path detection in image files

Bug #1087237 reported by Javier Collado
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
UTAH
Fix Released
Low
Javier Collado

Bug Description

This is a follow-up of:
https://code.launchpad.net/~nuclearbob/utah/iso-static-analysis-updates/+merge/138164

I'm concerned about the words `kernel` or `linux` appear anywhere in a line and getting a string that isn't a real kernel file path.

The proposed alternative is that instead of this:

if 'kernel' in line or 'linux' in line:
    newkernel = line.split()[1].strip('./')

We use something like this:

import re

...

match = re.match('^\s+(kernel|linux)\s+(?P<path>[^\s]+).*', line)
if match:
    newkernel = match.group('path')

Related branches

Changed in utah:
status: New → Triaged
importance: Undecided → Low
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Ah, I see the rational of mis-detection.
So:
if line.split()[0] in ('kernel', 'linux'):
    newkernel = line.split()[1].strip('./')

Should satisfy that requirement? Split strips leading whitespace.
We could even introduce a temp variable to hold line.spit() list.....

Revision history for this message
Javier Collado (javier.collado) wrote :

Yes, I'd be happy with that (including the assignment of a temporary variable).
I think Max will like also your approach, so I'll create a merge proposal with
it.

Thanks for your feedback.

Changed in utah:
assignee: nobody → Javier Collado (javier.collado)
Changed in utah:
status: Triaged → Fix Committed
Changed in utah:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.