Page 1 of 1

Ignore large block of text

Posted: Thu Feb 22, 2024 12:36 pm
by AlexFeren
Hello!
Fortigate configuration file has a large block of text containing PEM-formatted certificate and key, which get updated at every backup.

For example:

Code: Select all

        set private-key "-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABCGR2b7mr
:
:
qcRimIuw==
-----END OPENSSH PRIVATE KEY-----"
I'd like ExamDiff ignore it. How can I do?
R's, Fern.

Re: Ignore large block of text

Posted: Thu Feb 22, 2024 4:27 pm
by psguru
If these lines have consistent line numbers (say from line 1 to line 7), you can ignore then by line ranges (under Options | Text Comparison).

Re: Ignore large block of text

Posted: Thu Feb 22, 2024 4:28 pm
by AlexL
You publushed your question in the forum of ExamDiff Pro, but the question wording mentions ExamDiff.
I'll assume that you meant ExamDiff Pro.
In this case, I would try the following:
Menu -> Tools -> Options... -> Text Comparison -> Ignore lines -> Line ranges
And specify there the exact amount of lines to ignore, I think it's 7 lines in your case.
By the way, when you have entered that configuration menu, you can use <F1> button to get help about format of specifying the number (or even range) of ignored lines.
Don't forget to remove this setting when you compare other files which do not need such ignoration. Settings are saved.

Re: Ignore large block of text

Posted: Thu Feb 22, 2024 9:14 pm
by AlexFeren
Hello! No, the line numbers for these blocks of text aren't static - varying each time the configuration backup is generated. Moreover, their length isn't static - hence PEM format specifies the delimiters. Moreover, there are multiples of these spread out through the configuration file...

Re: Ignore large block of text

Posted: Fri Feb 23, 2024 9:03 am
by psguru
Then another option is to use the ignore regular expressions option, if you can come with one that is. These can be multi-line.

Re: Ignore large block of text

Posted: Sun Feb 25, 2024 7:55 pm
by AlexFeren
> Then another option is to use the ignore regular expressions option, if you can come with one that is. These can be multi-line.
Surely, a ExamDiff can make this easier by implementing "Ignore multi-line text bounded by start and end text" feature?

Re: Ignore large block of text

Posted: Mon Feb 26, 2024 10:31 am
by psguru
Yes, it would be but it's never come up until now. For now, you can create a new document type and define your own "comments" for it using a regular expression, like this for C comments:

Code: Select all

/\\*.*?\\*/

Re: Ignore large block of text

Posted: Mon Feb 26, 2024 5:41 pm
by AlexFeren
Hi... Can you propose the regular expression given the specification in previous post?

Re: Ignore large block of text

Posted: Mon Feb 26, 2024 7:53 pm
by psguru
Are there unique start/end words that delimit your "comments"? If so, use something like:

Code: Select all

word1.*?word2

Re: Ignore large block of text

Posted: Wed Feb 28, 2024 7:14 pm
by AlexFeren
Are there unique start/end words that delimit your "comments"?
This:

Code: Select all

        set private-key "-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABCGR2b7mr
:
:
qcRimIuw==
-----END OPENSSH PRIVATE KEY-----"

Re: Ignore large block of text

Posted: Mon Mar 04, 2024 10:41 pm
by AlexFeren
psguru wrote: Mon Feb 26, 2024 10:31 am For now, you can create a new document type and define your own "comments" for it using a regular expression, like this for C comments:
Suggestions?

Re: Ignore large block of text

Posted: Tue Mar 05, 2024 8:52 am
by psguru
I gave you a suggestion earlier: use a regex like this

Code: Select all

word1.*?word2
where word1/2 are unique starting/ending texts of the ignored block.

Re: Ignore large block of text

Posted: Wed Mar 20, 2024 5:57 am
by JeremyNicoll
Perhaps another option would be to write a simple 'plugin' which strips out the blocks of lines
you're not interested in. Possibly you'd want the plugin to leave a single line where each such
block had been saying "There was a key definition here." or even (if the number of them
matters) "Key definition nnnnn was here."

Re: Ignore large block of text

Posted: Tue May 07, 2024 3:11 pm
by AlexFeren
psguru wrote: Tue Mar 05, 2024 8:52 am I gave you a suggestion earlier: use a regex like this

Code: Select all

word1.*?word2
where word1/2 are unique starting/ending texts of the ignored block.
Hi! I already answered that - showing exact syntax of the block and no - it don't work. This warrants a dedicated feature in ExamDiff.

Re: Ignore large block of text

Posted: Tue May 07, 2024 3:17 pm
by psguru
Please provide screenshots illustrating the issue.