Skip to content

Commit

Permalink
client: Export Client Map
Browse files Browse the repository at this point in the history
Signed-off-by: kingthorin <[email protected]>
  • Loading branch information
kingthorin committed Jan 6, 2025
1 parent 6b96a7b commit e1e741e
Show file tree
Hide file tree
Showing 5 changed files with 490 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
import org.zaproxy.addon.client.ui.PopupMenuClientHistoryCopy;
import org.zaproxy.addon.client.ui.PopupMenuClientOpenInBrowser;
import org.zaproxy.addon.client.ui.PopupMenuClientShowInSites;
import org.zaproxy.addon.client.ui.PopupMenuExportClientMap;
import org.zaproxy.addon.commonlib.ExtensionCommonlib;
import org.zaproxy.addon.network.ExtensionNetwork;
import org.zaproxy.zap.ZAP;
Expand Down Expand Up @@ -294,6 +295,13 @@ public void hook(ExtensionHook extensionHook) {
.getMainFrame()
.getMainFooterPanel()
.addFooterToolbarRightComponent(pscanStatus.getCountLabel());

extensionHook
.getHookMenu()
.addPopupMenuItem(
new PopupMenuExportClientMap(
Constant.messages.getString("client.tree.popup.export.menu"),
this));
}
}

Expand Down Expand Up @@ -856,4 +864,8 @@ public void sessionModeChanged(Mode mode) {
}
}
}

public ClientMap getClientTree() {
return clientTree;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@

@Getter
@AllArgsConstructor
public class ClientSideComponent {

public static String REDIRECT = "Redirect";
public class ClientSideComponent implements Comparable<ClientSideComponent> {
public static final String REDIRECT = "Redirect";

private final Map<String, String> data;

Expand Down Expand Up @@ -122,4 +121,97 @@ public boolean equals(Object obj) {
&& Objects.equals(tagName, other.tagName)
&& Objects.equals(text, other.text);
}

@Override
public int compareTo(ClientSideComponent other) {
if (this.type.compareTo(other.type) > 0) {
return 1;
} else if (this.type.compareTo(other.type) < 0) {
return -1;
} else {
// Types are the same, Check next relevant property(ies)
switch (this.type) {
case "Cookies", "localStorage", "sessionStorage":
return storageCompareTo(other);
case "Button":
return buttonCompareTo(other);
case "Link":
return linkCompareTo(other);
case "Input":
return inputCompareTo(other);
case "FORM":
return formCompareTo(other);
default:
return 0;
}
}
}

int formCompareTo(ClientSideComponent other) {
if (this.id.compareTo(other.id) > 0) {
return 1;
} else if (this.id.compareTo(other.id) < 0) {
return -1;
} else {
if (this.formId > other.formId) {
return 1;
} else if (this.formId < other.formId) {
return -1;
} else {
return this.text.compareTo(other.text);
}
}
}

int inputCompareTo(ClientSideComponent other) {
if (this.tagType.compareTo(other.tagType) > 0) {
return 1;
} else if (this.tagType.compareTo(other.tagType) < 0) {
return -1;
} else {
if (this.id.compareTo(other.id) > 0) {
return 1;
} else if (this.id.compareTo(other.id) < 0) {
return -1;
} else {
return this.text.compareTo(other.text);
}
}
}

int linkCompareTo(ClientSideComponent other) {
if (this.href.compareTo(other.href) > 0) {
return 1;
} else if (this.href.compareTo(other.href) < 0) {
return -1;
} else {
return this.text.compareTo(other.text);
}
}

int buttonCompareTo(ClientSideComponent other) {
if (this.formId > other.formId) {
return 1;
} else if (this.formId < other.formId) {
return -1;
} else {
return this.text.compareTo(other.text);
}
}

int storageCompareTo(ClientSideComponent other) {
if (this.href != null && other.href != null && this.href.compareTo(other.id) > 0) {
return 1;
} else if (this.href != null && other.href != null && this.href.compareTo(other.id) < 0) {
return -1;
} else {
if (this.id.compareTo(other.id) > 0) {
return 1;
} else if (this.id.compareTo(other.id) < 0) {
return -1;
} else {
return this.text.compareTo(other.text);
}
}
}
}
Loading

0 comments on commit e1e741e

Please sign in to comment.