-
Notifications
You must be signed in to change notification settings - Fork 585
Feature: Semver Function #4582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
scudette
merged 7 commits into
Velocidex:master
from
nullifysecurity:feature/semver-function
Dec 10, 2025
Merged
Feature: Semver Function #4582
scudette
merged 7 commits into
Velocidex:master
from
nullifysecurity:feature/semver-function
Dec 10, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scudette
reviewed
Dec 10, 2025
Contributor
scudette
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let also add the example you have in the PR description to a test here
https://github.com/Velocidex/velociraptor/blob/master/artifacts/testdata/server/testcases/
Contributor
Author
|
Thanks @scudette, have made those improvements and added some tests as well. 😄 |
scudette
pushed a commit
that referenced
this pull request
Dec 23, 2025
# Feature Description
This pull request implements a new `semver` function which adds support
for parsing and comparison of semantic version strings.
With the uptick of supply chain compromises we're seeing recently, this
gives investigators the ability to parse and compare semantic versions
from package management files such as `package.json` to scan and detect
potentially vulnerable or compromised package versions.
The semantic version parsing and comparison is provided by the
`github.com/Masterminds/semver/v3` package which Velociraptor is already
utilising, removing the need for any additional dependencies.
The function itself extracts the major, minor, patch, and pre-release
values from the provided semantic version string and allows comparison
against other `semver` outputs and semantic version strings (similar to
the timestamp functionality). It supports the greater than, less than
and equal comparisons.
## semver
Parse a semantic version string.
Arg | Description | Type
----|-------------|-----
version | A string to convert to a semantic version | string (required)
# Examples
The following are some examples of `semver` function usage,
```text
-- Semver output
SELECT semver(version="v1.2.5-dev") AS Version FROM scope()
{
"Major":1
"Minor":2
"Patch":5
"Prerelease":"dev"
"Version":"1.2.5-dev"
}
-- Comparison against version strings
SELECT semver(version="1.0.0") = "1.0.0" FROM scope() -- True
SELECT semver(version="1.0.0") = "2.0.0" FROM scope() -- False
SELECT semver(version="1.0.0") <= "2.0.0" FROM scope() -- True
SELECT semver(version="1.0.0") >= "2.0.0" FROM scope() -- False
SELECT semver(version="2.0.0") AS Version FROM scope() WHERE Version > "1.0.0" -- True
-- Comparison against semver functions
SELECT semver(version="1.0.0") = semver(version="2.0.0") FROM scope() -- False
SELECT semver(version="1.0.0") < semver(version="1.1.0") FROM scope() -- True
SELECT semver(version="1.0.0") > semver(version="0.1.0") FROM scope() -- True
SELECT semver(version="1.0.0") > semver(version="v0.1.0-dev") FROM scope() -- True
SELECT "2.0.0" AS Version FROM scope() WHERE semver(version="1.0.0") < Version -- True
```
Please let me know if any improvements can be made to make this better
match Velociraptor's code style and design.
scudette
pushed a commit
that referenced
this pull request
Dec 23, 2025
# Feature Description
This pull request implements a new `semver` function which adds support
for parsing and comparison of semantic version strings.
With the uptick of supply chain compromises we're seeing recently, this
gives investigators the ability to parse and compare semantic versions
from package management files such as `package.json` to scan and detect
potentially vulnerable or compromised package versions.
The semantic version parsing and comparison is provided by the
`github.com/Masterminds/semver/v3` package which Velociraptor is already
utilising, removing the need for any additional dependencies.
The function itself extracts the major, minor, patch, and pre-release
values from the provided semantic version string and allows comparison
against other `semver` outputs and semantic version strings (similar to
the timestamp functionality). It supports the greater than, less than
and equal comparisons.
## semver
Parse a semantic version string.
Arg | Description | Type
----|-------------|-----
version | A string to convert to a semantic version | string (required)
# Examples
The following are some examples of `semver` function usage,
```text
-- Semver output
SELECT semver(version="v1.2.5-dev") AS Version FROM scope()
{
"Major":1
"Minor":2
"Patch":5
"Prerelease":"dev"
"Version":"1.2.5-dev"
}
-- Comparison against version strings
SELECT semver(version="1.0.0") = "1.0.0" FROM scope() -- True
SELECT semver(version="1.0.0") = "2.0.0" FROM scope() -- False
SELECT semver(version="1.0.0") <= "2.0.0" FROM scope() -- True
SELECT semver(version="1.0.0") >= "2.0.0" FROM scope() -- False
SELECT semver(version="2.0.0") AS Version FROM scope() WHERE Version > "1.0.0" -- True
-- Comparison against semver functions
SELECT semver(version="1.0.0") = semver(version="2.0.0") FROM scope() -- False
SELECT semver(version="1.0.0") < semver(version="1.1.0") FROM scope() -- True
SELECT semver(version="1.0.0") > semver(version="0.1.0") FROM scope() -- True
SELECT semver(version="1.0.0") > semver(version="v0.1.0-dev") FROM scope() -- True
SELECT "2.0.0" AS Version FROM scope() WHERE semver(version="1.0.0") < Version -- True
```
Please let me know if any improvements can be made to make this better
match Velociraptor's code style and design.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Feature Description
This pull request implements a new
semverfunction which adds support for parsing and comparison of semantic version strings.With the uptick of supply chain compromises we're seeing recently, this gives investigators the ability to parse and compare semantic versions from package management files such as
package.jsonto scan and detect potentially vulnerable or compromised package versions.The semantic version parsing and comparison is provided by the
github.com/Masterminds/semver/v3package which Velociraptor is already utilising, removing the need for any additional dependencies.The function itself extracts the major, minor, patch, and pre-release values from the provided semantic version string and allows comparison against other
semveroutputs and semantic version strings (similar to the timestamp functionality). It supports the greater than, less than and equal comparisons.semver
Parse a semantic version string.
Examples
The following are some examples of
semverfunction usage,Please let me know if any improvements can be made to make this better match Velociraptor's code style and design.