-
Notifications
You must be signed in to change notification settings - Fork 71
Improve RedHat OS detection #1079
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
Merged
Changes from 3 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
abf7d22
Improve RedHat OS detection
JSCU-CNI 5097c42
change parse_hostname_string to callable tuple
JSCU-CNI 1f90a29
Apply suggestions from code review
JSCU-CNI ce49013
add os detection tests
JSCU-CNI f075088
fix linter
JSCU-CNI 4c5f8a2
Merge branch 'main' into improvement/redhat-detection
JSCU-CNI 2de869f
make _parse_hostname_string return tuple
JSCU-CNI eb633af
Apply suggestions from code review
JSCU-CNI 577e76a
fix py3.9 tests
JSCU-CNI de813d5
Merge branch 'main' into improvement/redhat-detection
JSCU-CNI 371dc0a
Merge branch 'main' into improvement/redhat-detection
Schamper 3097eb7
implement review comments
JSCU-CNI 43505c6
Change _parse_hosts_string & add test_parse_domain test case
Horofic 9394c1c
Adjust tests
Horofic 3f6f6bb
Revert "Adjust tests"
Horofic 343c12a
Change domain property behaviour
Horofic c065510
Merge branch 'main' into improvement/redhat-detection
JSCU-CNI File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,26 @@ | ||
| from typing import Optional | ||
| from __future__ import annotations | ||
|
|
||
| from dissect.target.filesystem import Filesystem | ||
| from dissect.target.plugins.os.unix.linux._os import LinuxPlugin | ||
| from dissect.target.target import Target | ||
|
|
||
|
|
||
| class RedHatPlugin(LinuxPlugin): | ||
| """RedHat, CentOS and Fedora Plugin.""" | ||
|
|
||
| def __init__(self, target: Target): | ||
| super().__init__(target) | ||
|
|
||
| @classmethod | ||
| def detect(cls, target: Target) -> Optional[Filesystem]: | ||
| # also applicable to centos (which is a red hat derivative) | ||
| for fs in target.filesystems: | ||
| if fs.exists("/etc/sysconfig/network-scripts"): | ||
| return fs | ||
| def detect(cls, target: Target) -> Filesystem | None: | ||
| REDHAT_PATHS = { | ||
| "/etc/centos-release", | ||
| "/etc/fedora-release", | ||
| "/etc/redhat-release", | ||
| "/etc/sysconfig/network-scripts", # legacy detection | ||
| } | ||
|
|
||
| return None | ||
| for fs in target.filesystems: | ||
| for path in REDHAT_PATHS: | ||
| if fs.exists(path): | ||
| return fs |
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
Schamper marked this conversation as resolved.
Show resolved
Hide resolved
|
Empty file.
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
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.
Uh oh!
There was an error while loading. Please reload this page.