Feat: SEL-362X Module - #79
Conversation
|
Thanks for opening a draft. Just a FYSA, my very first review comment will be asking you to squash those 285 glorious commits 😁 |
| @@ -0,0 +1,521 @@ | |||
| # Configuration file for PEAT (the Process Extraction and Analysis Tool) | |||
There was a problem hiding this comment.
cut this config down to just the fields that have changed or are otherwise being used/are relevant.
|
Main branch has been cold-pressed. |
| return AdvancedRange(low, high) | ||
|
|
||
|
|
||
| class Method: |
There was a problem hiding this comment.
Encapsulating pull methods as objects is something I've wanted to do for a long time. Maybe you could be the chosen one and finally bring this to the PEAT API?!?!
Scan uses IdentifyMethod, but Pull is a basic override of Device._pull(). Instead of that nonsense, define PullMethod instances that the device can select and use based on configuration options, verification status, etc just like for IdentifyMethod and scan.
There was a problem hiding this comment.
I may consider working on that eventually, if happenstance permits it.
|
note: remove email from docstrings, policy for peat is all requests should go to |
4d84aef to
a44d10c
Compare
|
This should be ready for review, but I do not know why GitHub is preventing me from adding tags to the PR (which needs to be labeled as a feature addition). |
You likely can't tag because you're not a Maintainer for the project, just like I can't anymore 😅. No worries, @BugFriendlyGarden can tag/label as appropriate. Can you please update the PR title to align with conventional commit style? e.g. "feat: 362x module" I'll give this a proper review if I have some spare time tomorrow, otherwise it'll likely be next week. Fear not, there will definitely be comments 😈 |
|
Biggest issue tho before I review everything else is there are way too many source files. one-function-per-file is excessive, it leads to a lot of import-related boilerplate, duplication, and hard to trace code, not to mention super cluttered folder. Follow the pattern other modules have of consolidating related functions into a single file or small set of files, e.g. data-model related functions in a "362x_processing" and data parsing in "362x_parsing.py". I leave the approach up to you. |
There were other requirements (namely collaboration) that I had to consider for this project, but it should be fairly straightforward to fix this. |
|
I have reduced this to six files. Do let me know if that is still too much. |
| Author: Francisco Santana | ||
| """ | ||
|
|
||
| # TODO: This needs to be updated to better support the SEL-3620 or R212 of the firmware. |
There was a problem hiding this comment.
Create a github issue to track this. if you can, include in the issues more details about what issues you ran into specifically (make sure not to include any sensitive info, if you're uncertain talk with your project lead). This is so someone picking up your work in the future has somewhere to start.
GhostofGoes
left a comment
There was a problem hiding this comment.
Ok, this is a big review. Don't take it the wrong way, you did great work here, and it made me want to give it a proper deep review. You really dug deep into the device and got a lot of information. Good work on error handling, type annotations, and comments.
| peat_module: "sel-362x" | ||
| options: | ||
| https: | ||
| port: 10443 |
There was a problem hiding this comment.
I interacted with the 3620 using SSH port forwarding, though I could change it to 443.
There was a problem hiding this comment.
yeah change to 443, this is meant to be a general example
| """ | ||
| SEL-362X Family of Security Gateways. | ||
|
|
||
| This module is designed to support both the SEL-3622 and the SEL-3620, though |
There was a problem hiding this comment.
One major concern I have is the module name. There is already a module for the SEL-3620.
Does the 362X module also work with the 3620?
- If so, then the modules need to be combined.
- If not, probably should differentiate this module somehow, e.g. rename to
SEL3622.
There was a problem hiding this comment.
The plan is to replace the 3620 module eventually, but keep the old one for compatibility for now.
There was a problem hiding this comment.
Can you document that somewhere? My concern is if there's a 3620 on the network, there could be two peat modules activated simultaneously, with odd results. Have you tested against the peat rack with all modules enabled? e.g. peat pull -i <rack-subnet> (all defaults)
There was a problem hiding this comment.
This module seemingly takes precedence over the 3620 module due to the higher reliability rating. For now, I removed the aliases to the 3620 on my module.
| was originally developed for the former. | ||
|
|
||
| Authors: | ||
| - Francisco Santana |
There was a problem hiding this comment.
If Nehal contributed code, both of you should be added to the AUTHORS file
|
|
||
| class SEL362X(DeviceModule): | ||
| """ | ||
| SEL-3620 Security Gateway |
There was a problem hiding this comment.
see earlier comment about duplication with SEL3620
| vendor_id = "SEL" | ||
| vendor_name = "Schweitzer Engineering Laboratories" | ||
| brand = "SEL" | ||
| module_aliases = ["sel-3622", "sel-3620", "sel-362x", "3622", "3620", "362x"] |
There was a problem hiding this comment.
this overlaps with the existing SEL3620 module
| return result | ||
|
|
||
|
|
||
| def parse_free_mem(lines: list[str]) -> dict[str, Any]: |
| return result | ||
|
|
||
|
|
||
| def parse_process_list(lines: list[str]) -> list[dict[str, Any]]: |
|
|
||
| def pull_syslog_settings(dev: DeviceData, session: HTTP362X) -> dict[str, Any]: | ||
| """ | ||
| Pull the configuration under /Syslog.sel |
There was a problem hiding this comment.
You can probably re-use a lot of the parsing and processing code from SEL3620 and SELRTAC modules.
| Releases | ||
| ======== | ||
|
|
||
| - Added support for pulling and parsing configuration data for the SEL-3622/3620 Security Gateway (Tested for Firmware R200 and R212, respectively) |
There was a problem hiding this comment.
This should be a towncrier snippet. Was a relatively recent change to peat, talk to @BugFriendlyGarden
There was a problem hiding this comment.
I should probably ask him about that. Thanks for telling me!
There was a problem hiding this comment.
Yeah, the change is documented in CONTRIBUTING.rst under Update the CHANGELOG.
I'm working on making the new requirement clear. You just need to put your new text above into a file called newsfragments/79.feature
When we create the next release, we'll run a tool called towncrier that digests all of the newsfragments files to automatically update the CHANGELOG.rst file.
There was a problem hiding this comment.
Good to know. I just added a file to my repo -- feel free to correct it.
| {file = "tomlkit-0.14.0.tar.gz", hash = "sha256:cf00efca415dbd57575befb1f6634c4f42d2d87dbba376128adb42c121b87064"}, | ||
| ] | ||
|
|
||
| [[package]] |
There was a problem hiding this comment.
revert changes to pdm.lock
e317810 to
d79bbef
Compare
@GhostofGoes Does tag in this case only refer to release tags? It's the only one I see in CONTRIBUTING.md. |
a4293e2 to
f1700e1
Compare
Labels is the proper term.
|
34397cf to
6cd692c
Compare
| def do_hash(hcons: Callable[..., _Hash], data: str) -> str: | ||
| """Get a HASH object from `hcons`, then make a digest of `data`""" | ||
| hobj = hcons(usedforescurity=False) | ||
| hobj.update(data.encode()) |

SEL-362X Module
Description
This PR aims to implement support for the SEL-362X family of products. While originally intended for the SEL-3622, this module ended up providing partial support for the SEL-3620. This module currently supports both products.
Please check the following items as they're completed.
Completion of all checklist items signals to maintainers that a PR is fully ready for review.
CHANGELOG.rst