-
Notifications
You must be signed in to change notification settings - Fork 881
Allow inline # comments in all alias types (network/host/port) #9353
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
base: master
Are you sure you want to change the base?
Conversation
|
I don't expect we will merge this to be honest, we removed similar input styles years ago for good reasons, aliases can be nested easily to document separate items. |
|
I know, I already saw that also on the forum (here for example) every time someone ask for the ability to comment on each line of aliases the solution proposed it's always "simply use nested aliases".
Sorry, but I think that "easily" it's a bit subjective in this case. Nested aliases method really don't scale well at all. Here is an example: I need to nat 50 different random ports for 50 services on different servers. Using the
At this point I just completed 50 ports for 50 services only on server 1 Now start all over again for server 2 that has same services on different ports so you need to make 50 more aliases to document what service and server these port refers to and you cannot re-use the aliases from server 1 because equal services uses different ports on the 2 server. Using the
I came from OPNsense 18 that had this user interface with the ability of commenting each line: I understand that for some technical reason this kind of data input has been abandoned in favor of one line data. Sorry but I don't understand this rigidity and why we cannot have a piece of software that can accomodate different use cases of different user. I want also to mention that after 100+ aliases to create nested aliases the drop menu with its 5 lines becomes really clogged and hard to consult (yes I know I can use search in the drop menu, but this imply that someone know what to search that's different from have a list under the eyes). |
|
If the problem is bulk input, changing the data format is still not the right direction. Data entry is just not a data model issue. (p.s. try to dump a comma in your comment for fun) |
src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/AliasContentField.php
Outdated
Show resolved
Hide resolved
|
From a different perspective this looks like some kind of Macro actions are missing that would turn repetitive actions into one automatic flow. E.g. "Create a nested alias with these 1000 ports". Though if you look at Macros in other software (e.g. excel) they are programmed via VBS or another script language. The aliases do have an API endpoint, so you could automate your repetitive workflows via a script language as well. |
|
Thanks for the answer.
then if you want to delete/edit all these aliases? what I'm supposed to do? write a Macro every time I need to make some bulk change? And the clogged drop menu with these 1000 aliases? I could make a file excel with the ports on a column and the description in another column and copy/paste the first column in an alias in OPNsense. But this way the documentation of my ports is only on my pc and not in the OPNsense machine. This approach wants me to be able to access that file, and I cannot do any change on the fly without that excel. And when someone else will need to make some changes will be hit by a wall of not documented ports.
I could also configure all OPNsense using the shell and some script but would be time consuming and with a learning curve, so I'd prefer not to do that and rely on a flexible webUI. Like in this case, I would prefer to makes these changes on the webUI. |
each port is a different service, if I use a range how can I document in the alias description to wich service a specific port of the port range refers to? |
|
But this work has already been done by IANA: https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?&page=1 |
But if I want to use random ports on a service instead of the one proposed by IANA for example to make it harder for automated bot/scripts to check what service I'm running? Like for example openVPN not on the 1124 port.. However the "50 different random ports for 50 services on different servers" was only one of the possible example of why someone would want to comment a bunch of entries in the alias "content" field instead of having to nest aliases. |
… "," comma now aliases commenting can handle: - port1, port2 #comment - port1 #comment1, port2 #comment2 to make this possible now it's NOT allowed: - port1 #comment, with, commas
|
It's unlikely this will make it in because it's still a validation nightmare with regression potential and introduced technical debt. Also the importance looks more like "affects only me". |
|
It's not true, it doesn't affect only me. I found a lot of people that in the years asked on the OPNsense forum or on github the ability to comment the aliases, but from the maintainers of this project they got only: "use nested aliases instead". This changes are less than 10 lines of code for each file for 4 files. If there is a regression you can simply go back to the previous code, I'm pretty sure github allows that. At least can this PR become some kind of plug-in? |
|
Good question.
Let me answer with what I already wrote.
|
|
as I already told the context was:
Tried to make a plugin: https://github.com/I-G-1-1/opnsense_plugins/tree/master/security/advancedalias |











Summary:
This PR makes it possible to use inline comments (with '#') on every alias type (host/network/port) both in the WebUI and during runtime rule generation.
Modified:
All patches use preg_replace('/\s*#.*$/', '', $line) logic per line, and ignore empty/commented lines.
How to test:
Fixes longstanding community requests for better in-place documentation of firewall configs.