[Fix] Logical and Formatting Issues in IncrementalPad Function (Issue #642)#670
Merged
Mzack9999 merged 4 commits intoprojectdiscovery:mainfrom Aug 29, 2025
Merged
Conversation
Contributor
Author
|
It seems that the ASN related test is broken with 401 (unauthorized) due to lack of API key, and there are no other unusual results from the test. |
Mzack9999
approved these changes
Aug 29, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix zero‑padding encoding for IPv4 (
-zpp,-zpn) and remove duplicatesSummary
This PR fixes the IPv4 zero‑padding feature used by
-zpp(zero‑pad permutations) and-zpn(max width) so that it:-zpnvalue (no off‑by‑one).ip_test.go) that verify both correctness and absence of duplicates.Tested on Windows and Linux; the changes are limited to the IP encoding helpers.
Motivation & linked issue
Fixes the behaviour reported in #642:
padding=2andip=192.168.1.1, the result was always192.168.1.1instead of the expected permutations, e.g.192.168.1.1,192.168.1.01,192.168.01.1,192.168.01.01.This PR addresses both problems and aligns the feature with the CLI flags’ intent.
Issues:
%#0Nswith strings does not match numeric zero‑padding semantics and produced surprising results.p? < paddingwith0‑based widths, so-zpn Neffectively meant widths0..N-1→ off‑by‑one.Improvements:
%0*d) so zero‑padding is applied to integer octets exactly like users expect.-zpn Nnow truly permits widths1..N. (No off‑by‑one.)len(parts) != 4andpadding < 1cases are handled safely.CLI examples
-zpn 2(with-zpp)-zpn 3(with-zpp)Tests
TestIpEncodingsinip_test.goto assert:1..Nfor-zpn N.FixedPadpads to exactly N digits per octet.Example run:
Complexity & performance
N<=3).Backward compatibility
-zpn. If someone relied on the previous “N means N-1” behaviour, their result set will expand (never shrink), which is the expected and documented meaning of a “max width”.-zpn 1remains identical to the original address (no leading zeros).Checklist
-zpn%0*dformattingip_test.go)