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

added two new options to the forced-browse add-on. #1534

Merged
merged 2 commits into from Apr 16, 2018
Merged

added two new options to the forced-browse add-on. #1534

merged 2 commits into from Apr 16, 2018

Conversation

KajanM
Copy link
Contributor

@KajanM KajanM commented Apr 9, 2018

as part of #173 following options in DirBuster are brought to Forced Browse add-on.
HTML Parsing Options > File extensions to not process
Scan Options > Fail Case String

@KajanM KajanM changed the title Tighter DirBuster Integration Fix zaproxy/zaproxy #173 Tighter DirBuster Integration Apr 9, 2018
Copy link
Member

@kingthorin kingthorin left a comment

Choose a reason for hiding this comment

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

Haven’t tested it yet, here’s a few things.

List<String> extensionsToMissList = new ArrayList<>();
for (String extensionToMiss: extensionsToMiss.replaceAll("\\s",
EMPTY_STRING).split(",")) {
if (!extensionToMiss.equals(EMPTY_STRING)) {
Copy link
Member

Choose a reason for hiding this comment

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

How about !extensionToMiss.isEmpty()

Copy link
Member

Choose a reason for hiding this comment

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

Actually there’s also probably a way to do this without a loop and using addAll. Should the code handle duplicates? If it was all put in a set I believe that’d ensure unique entries...

if (failCaseString == null) {
throw new IllegalArgumentException("failCaseString is null");
}
if (!"".equals(failCaseString)) {
Copy link
Member

Choose a reason for hiding this comment

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

Should use isEmpty as mentioned above.

@@ -13,6 +13,8 @@ bruteforce.options.button.addfile = Select File...
bruteforce.options.label.addfile = Add custom Forced Browse file:
bruteforce.options.label.browsefiles = Force Browse files
bruteforce.options.label.defaultfile = Default file:
bruteforce.options.label.extensionsToMiss = File extensions to not process (separated by ,):
Copy link
Member

Choose a reason for hiding this comment

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

I think “ignore” might be more clear than ‘not process’.

@KajanM
Copy link
Contributor Author

KajanM commented Apr 10, 2018

Suggestions are addressed and ready for the review.

@psiinon
Copy link
Member

psiinon commented Apr 11, 2018

@KajanM could you update https://github.com/zaproxy/zap-extensions/blob/beta/src/org/zaproxy/zap/extension/bruteforce/resources/help/contents/options.html to add the new options?

@@ -58,7 +58,8 @@
private boolean recursive = BruteForceParam.DEFAULT_RECURSIVE;
private DirBusterManager manager = null;
private List<String> extensions = null;

private Vector<String> extsToMissVector = null;

Copy link
Member

Choose a reason for hiding this comment

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

A space was accidentally added.


public static final int DEFAULT_THREAD_PER_SCAN = 10;
public static final int MAXIMUM_THREADS_PER_SCAN = 200;
public static final boolean DEFAULT_RECURSIVE = true;
public static final boolean DEFAULT_BROWSE_FILES = false;
public static final String EMPTY_STRING = "";
public static final String DEFAULT_EXTENSIONS_TO_MISS = "jpg, gif, jpeg, ico, tiff, png, bmp";
public static final String DEFAULT_FAIL_CASE_STRING = Config.failCaseString;
public static final String WHITESPACE = "\\s";
Copy link
Member

Choose a reason for hiding this comment

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

This should be private.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@thc202 DEFAULT_EXTENSIONS_TO_MISS, DEFAULT_FAIL_CASE_STRING are also used in OptionsBruteForcePanel.java. Should I provide getter method or leave it public?

Copy link
Member

Choose a reason for hiding this comment

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

Those are fine, I just mean WHITESPACE and COMMA (though it applies to EMPTY_STRING as well), we don't really want other classes to depend on this class just because of these generic constants.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for the misunderstanding.
As of this comment and this thread, I removed WHITESPACE and COMMA constants.

Copy link
Member

Choose a reason for hiding this comment

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

No problem.
Sounds good.

public static final String DEFAULT_EXTENSIONS_TO_MISS = "jpg, gif, jpeg, ico, tiff, png, bmp";
public static final String DEFAULT_FAIL_CASE_STRING = Config.failCaseString;
public static final String WHITESPACE = "\\s";
public static final String COMMA = ",";
Copy link
Member

Choose a reason for hiding this comment

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

Same here, also do we really need a constant for this? (If so, it should probably have a more meaningful name, like EXTENSION_SEPARATOR.)


/**
* @return {@code String} of comma-separated file-extensions that are not to be processed.
* {@code "jpg, gif, jpeg, ico, tiff, png, bmp"} is returned by default
Copy link
Member

Choose a reason for hiding this comment

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

Probably better to link to the constant instead, otherwise this will have to be changed if we happen to add/remove an extension.


/**
* Define a {@code String} of comma-separated file-extensions for
* resources not to be processed
Copy link
Member

Choose a reason for hiding this comment

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

This could also use "ignore".

* {@code "jpg", "gif", "jpeg", "ico", "tiff", "png", "bmp"}
*
*/
public Vector<String> getExtensionsToMissVector() {
Copy link
Member

Choose a reason for hiding this comment

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

This could return the Set, let BruteForce convert it to Vector (actually BruteForce could just add them to the existing extsToMiss).

*
*/
public Vector<String> getExtensionsToMissVector() {
if (extensionsToMiss.trim().equals(EMPTY_STRING)) {
Copy link
Member

Choose a reason for hiding this comment

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

isEmpty()

if (failCaseString == null) {
throw new IllegalArgumentException("failCaseString is null");
}
if (!failCaseString.isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

If the empty string is not acceptable we should throw an exception instead (like above).
Also, this should be validated in OptionsBruteForcePanel to inform the user that it should not be left empty.

@thc202
Copy link
Member

thc202 commented Apr 11, 2018

I'm not sure this fixes the issue, we might want check if there's any other useful option (or functionality) that needs to be exposed (it does not need to be done in this PR though).

@kingthorin
Copy link
Member

kingthorin commented Apr 11, 2018

Ya the issue has comments about showing all traffic, following redirects, Files/dirs/both, recursion (done I think), request limits, etc

So the commit and PR messages should probably be changed.

@KajanM KajanM changed the title Fix zaproxy/zaproxy #173 Tighter DirBuster Integration added file-extensions-to-ignore, fail-case-string options to forced-browse add-on. Apr 11, 2018
@KajanM
Copy link
Contributor Author

KajanM commented Apr 11, 2018

@thc202 @kingthorin

I'm not sure this fixes the issue, ...

I will create a separate PR for other missing options. As I am new to open-source development I wanted to get some insights from the review before putting all the changes.

@kingthorin
Copy link
Member

No problem

@KajanM KajanM changed the title added file-extensions-to-ignore, fail-case-string options to forced-browse add-on. added two new options to the forced-browse add-on. Apr 13, 2018
@KajanM
Copy link
Contributor Author

KajanM commented Apr 13, 2018

Thank you for the review. Suggestions are addressed.

@@ -99,6 +99,7 @@ public BruteForce (ScanTarget target, File file, BruteForceListenner listenner,
} else {
extensions = Collections.emptyList();
}
extsToMissVector = new Vector<>(bruteForceParam.getExtensionsToMissSet());
Copy link
Member

Choose a reason for hiding this comment

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

I was suggesting change the extsToMiss directly, e.g.: manager.extsToMiss.addAll(bruteForceParam.getExtensionsToMissSet()) (which avoids changing setupManager).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wow, it is beautiful.

public void setFailCaseString(String failCaseString) {
if (failCaseString == null || failCaseString.isEmpty()) {
throw new IllegalArgumentException(
Constant.messages.getString("bruteforce.options.error.failCaseString.invalid"));
Copy link
Member

Choose a reason for hiding this comment

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

For exception messages not show directly in the UI we keep them in English.
The failCaseString is not being set to the configuration file.

@@ -10,9 +10,12 @@ bruteforce.desc = Forced browsing of files and directories u
bruteforce.dir.popup = Forced Browse directory
bruteforce.dir.and.children.popup = Forced Browse directory (and children)
bruteforce.options.button.addfile = Select File...
bruteforce.options.error.failCaseString.invalid = Invalid Fail Case String.
Copy link
Member

Choose a reason for hiding this comment

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

We should tell why it's invalid, better say something like "The Fail Case String should not be empty."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it possible to provide null value to the JTextField from the UI?
Is it enough to validate only for empty value?

Copy link
Member

Choose a reason for hiding this comment

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

No, it just returns an empty string. Yes.

@KajanM
Copy link
Contributor Author

KajanM commented Apr 13, 2018

Done.

@thc202
Copy link
Member

thc202 commented Apr 13, 2018

LGTM, there's just one thing missing, the ZapAddOn.xml needs to be updated, the version should be 8 and the changes replaced with a short description mentioning the options added.

@KajanM
Copy link
Contributor Author

KajanM commented Apr 13, 2018

Updated the ZapAddOn.xml and made setFailCaseString, getFailCaseString, getExtensionsToMissSet, setExtensionsToMiss, getExtensionsToMiss methods in BruteForceParam.java, package private.

@thc202
Copy link
Member

thc202 commented Apr 13, 2018

Note that the version was not updated. It was fine to leave them public also fine with package accessibility :) (+1 to the removal of the unused import.)

following options in DirBuster are brought to Forced Browse add-on.
HTML Parsing Options > File extensions to not process
Scan Options > Fail Case String
@KajanM
Copy link
Contributor Author

KajanM commented Apr 13, 2018

Version updated. Thank you for the time :)

@thc202
Copy link
Member

thc202 commented Apr 13, 2018

Thank you!

@thc202
Copy link
Member

thc202 commented Apr 16, 2018

@kingthorin looks good?

Copy link
Member

@kingthorin kingthorin left a comment

Choose a reason for hiding this comment

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

Yup, looks good to me.

@kingthorin kingthorin merged commit 0b1b852 into zaproxy:beta Apr 16, 2018
@kingthorin
Copy link
Member

Squashed and merged.

@KajanM KajanM deleted the beta branch April 16, 2018 11:18
@thc202
Copy link
Member

thc202 commented Apr 16, 2018

@KajanM how would you like to be credited?
https://github.com/zaproxy/zap-core-help/wiki/HelpCredits

@KajanM
Copy link
Contributor Author

KajanM commented Apr 16, 2018

Kajan Mohanagandhirasa(@GM_K4J4N)

thc202 added a commit to thc202/zap-core-help that referenced this pull request Apr 16, 2018
@KajanM
Copy link
Contributor Author

KajanM commented Apr 16, 2018

Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants