Skip to content

Fixing regex to be able to detect versions correctly for Huawei VRP#660

Merged
amcgough-r7 merged 4 commits intomainfrom
updating-huawei-vrp-type
Feb 18, 2026
Merged

Fixing regex to be able to detect versions correctly for Huawei VRP#660
amcgough-r7 merged 4 commits intomainfrom
updating-huawei-vrp-type

Conversation

@amcgough-r7
Copy link
Copy Markdown
Contributor

@amcgough-r7 amcgough-r7 commented Feb 13, 2026

Description

Allowing to detect all the versions of Huawei VRP with or with out the hot patch attached along with adding the device associated with Huawei VRP as os.device

Motivation and Context

Explanation of why these changes are being proposed, including any links to other relevant issues or pull requests.

How Has This Been Tested?

A clear and concise description of your changes were tested.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have updated the documentation accordingly (or changes are not required).
  • I have added tests to cover my changes (or new tests are not required).
  • All new and existing tests passed.

@amcgough-r7 amcgough-r7 changed the title Fixing regex to be able to detect versions correctly Fixing regex to be able to detect versions correctly for Huawei VRP Feb 13, 2026
Comment thread xml/snmp_sysdescr.xml Outdated
</fingerprint>

<fingerprint pattern="VRP.*Version ([\d.]+) \((.+?) (V[\d.]+R[\d.]+C[\d.]+(?:SPC|SPH|CP|HP)?\d*)">
<fingerprint pattern="VRP.*Version ([\d.]+) \(([^\s]+) (V\d{3,4}R\d{3,4}(?:C\d{2,3})?(?:SPC\d+|SPH\d+|CP\d+|HP\d+)?)\)">
Copy link
Copy Markdown
Contributor

@rkenna-r7 rkenna-r7 Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there examples where the series string contains 4 numbers after the V/R and 3 after the C?
all series strings i've seen would begin with V\d{3}R\d{3}(?:C\d{2} but perhaps ive missed some

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did check over the advisories again to make sure I wasn't missing anything with the version numbers, yes you would be correct there hasn't been reporting of those digits changing.

Comment thread xml/snmp_sysdescr.xml Outdated
</fingerprint>

<fingerprint pattern="VRP.*Version ([\d.]+) \((.+?) (V[\d.]+R[\d.]+C[\d.]+(?:SPC|SPH|CP|HP)?\d*)">
<fingerprint pattern="VRP.*Version ([\d.]+) \(([^\s]+) (V\d{3,4}R\d{3,4}(?:C\d{2,3})?(?:SPC\d+|SPH\d+|CP\d+|HP\d+)?)\)">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<fingerprint pattern="VRP.*Version ([\d.]+) \(([^\s]+) (V\d{3,4}R\d{3,4}(?:C\d{2,3})?(?:SPC\d+|SPH\d+|CP\d+|HP\d+)?)\)">
<fingerprint pattern="VRP(?:(?!VRP).)*?Version ([\d.]+) \(([^\s]+) (V\d{3,4}R\d{3,4}(?:C\d{2,3})?(?:SPC\d+|SPH\d+|CP\d+|HP\d+)?)\)">

Just wondering should you change to this so its not susceptible to DOS. I checked the original regex with this https://devina.io/redos-checker

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes fixed with your suggestion, I did forget this was a resource

Copy link
Copy Markdown
Contributor Author

@amcgough-r7 amcgough-r7 Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only thing is in go it doesn't seem to like this regex, changed to VRP[^V]*Version instead of your suggestion. Still works with the redos checker and regex matches on everything we need

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your new version looks good to me ;)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one

Copy link
Copy Markdown
Contributor

@stkelly-r7 stkelly-r7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM +1

@amcgough-r7 amcgough-r7 merged commit f3b2698 into main Feb 18, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants