Skip to content
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

fix: 🐛 fixes for \n characters in inappropriate places and parsing bug #416

Merged
merged 3 commits into from
Mar 28, 2024

Conversation

bile0026
Copy link
Contributor

Fix bad logic with line.startswith.
Add clean function to handle when lines are inappropriately split between double quotes in some backup files.

... }
... format {
... config "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$result|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial shost=$host cs3Label=Virtual System cs3=$vsys act=$cmd duser=$admin destinationServiceName=$client msg=$path externalId=$seqno PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags
... Optional: cs1Label=Before Change Detail cs1=$before-change-detail cs2Label=After Change Detail cs2=$after-change-detail";
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a note for review, this is an example of a newline inserted.

@qduk
Copy link
Collaborator

qduk commented Dec 7, 2023

Hey @bile0026. Thanks for the PR. Can you add tests for palo_alto_clean_newlines that show the following:

  • When no newline is used.
  • What happens when a match is found? e.g. does it concatenate it to a single line?
  • How does this affect the compliance?

@bile0026
Copy link
Contributor Author

Hey @bile0026. Thanks for the PR. Can you add tests for palo_alto_clean_newlines that show the following:

  • When no newline is used.
  • What happens when a match is found? e.g. does it concatenate it to a single line?
  • How does this affect the compliance?

Added tests for the first 2. Yes, it finds the rest of the line up to the " and concatenates it to a single line.

This is specific to when there's a \n character between quote marks "". These aren't supposed to be there but if a user copy/pastes a config into the GUI it will allow it. If these \n characters are in the backup config it breaks compliance rules and never shows up in the Golden Config section because GC ends up treating it like a new config section because it drops it to a new line without indentation.

this is a config line {
    section1 {
        configuration line
drops to a new line with no indent;
        next configuration line;
    }
}   

@bile0026 bile0026 force-pushed the palo_alto_logging_fixes branch from be2928e to e9b5dc0 Compare March 22, 2024 16:10
netutils/utils.py Outdated Show resolved Hide resolved
docs/user/include_jinja_list.md Outdated Show resolved Hide resolved
@itdependsnetworks
Copy link
Contributor

@qduk will merge by friday unless you have a concern.

Copy link
Collaborator

@qduk qduk left a comment

Choose a reason for hiding this comment

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

LGTM

@jeffkala jeffkala merged commit 8c390b1 into networktocode:develop Mar 28, 2024
19 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