-
-
Notifications
You must be signed in to change notification settings - Fork 674
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Websocket message en/decoding support for gRPC messages. Signed-off-by: amitpanwar789 <amitpanwar02705@gmail.com>
- Loading branch information
1 parent
3350e8c
commit f4f286a
Showing
13 changed files
with
190 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
102 changes: 102 additions & 0 deletions
102
.../grpc/src/main/java/org/zaproxy/addon/grpc/internal/websocket/ExtensionGrpcWebSocket.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Zed Attack Proxy (ZAP) and its related class files. | ||
* | ||
* ZAP is an HTTP/HTTPS proxy for assessing web application security. | ||
* | ||
* Copyright 2024 The ZAP Development Team | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.zaproxy.addon.grpc.internal.websocket; | ||
|
||
import java.util.List; | ||
import org.parosproxy.paros.Constant; | ||
import org.parosproxy.paros.extension.Extension; | ||
import org.parosproxy.paros.extension.ExtensionAdaptor; | ||
import org.parosproxy.paros.extension.ExtensionHook; | ||
import org.zaproxy.addon.grpc.ExtensionGrpc; | ||
import org.zaproxy.addon.grpc.internal.DecoderUtils; | ||
import org.zaproxy.addon.grpc.internal.HttpPanelGrpcView; | ||
import org.zaproxy.zap.extension.httppanel.view.HttpPanelView; | ||
import org.zaproxy.zap.extension.websocket.ExtensionWebSocket; | ||
import org.zaproxy.zap.extension.websocket.ui.httppanel.component.WebSocketComponent; | ||
import org.zaproxy.zap.extension.websocket.ui.httppanel.models.ByteWebSocketPanelViewModel; | ||
import org.zaproxy.zap.view.HttpPanelManager; | ||
|
||
public class ExtensionGrpcWebSocket extends ExtensionAdaptor { | ||
|
||
public static final String NAME = "ExtensionGrpcWebSocket"; | ||
private static final List<Class<? extends Extension>> DEPENDENCIES = | ||
List.of(ExtensionGrpc.class, ExtensionWebSocket.class); | ||
|
||
public ExtensionGrpcWebSocket() { | ||
super(NAME); | ||
} | ||
|
||
@Override | ||
public List<Class<? extends Extension>> getDependencies() { | ||
return DEPENDENCIES; | ||
} | ||
|
||
@Override | ||
public void hook(ExtensionHook extensionHook) { | ||
if (hasView()) { | ||
HttpPanelManager manager = HttpPanelManager.getInstance(); | ||
manager.addRequestViewFactory(WebSocketComponent.NAME, new WebSocketGrpcViewFactory()); | ||
manager.addResponseViewFactory(WebSocketComponent.NAME, new WebSocketGrpcViewFactory()); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean canUnload() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void unload() { | ||
HttpPanelManager manager = HttpPanelManager.getInstance(); | ||
manager.removeRequestViewFactory(WebSocketComponent.NAME, WebSocketGrpcViewFactory.NAME); | ||
manager.removeResponseViewFactory(WebSocketComponent.NAME, WebSocketGrpcViewFactory.NAME); | ||
} | ||
|
||
@Override | ||
public String getUIName() { | ||
return Constant.messages.getString("grpc.websocket.name"); | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return Constant.messages.getString("grpc.websocket.desc"); | ||
} | ||
|
||
private static final class WebSocketGrpcViewFactory | ||
implements HttpPanelManager.HttpPanelViewFactory { | ||
public static final String NAME = "WebSocketGrpcViewFactory"; | ||
|
||
@Override | ||
public String getName() { | ||
return NAME; | ||
} | ||
|
||
@Override | ||
public HttpPanelView getNewView() { | ||
return new HttpPanelGrpcView( | ||
new ByteWebSocketPanelViewModel(), DecoderUtils.DecodingMethod.DIRECT); | ||
} | ||
|
||
@Override | ||
public Object getOptions() { | ||
return null; | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
27 changes: 27 additions & 0 deletions
27
addOns/grpc/src/main/javahelp/org/zaproxy/addon/grpc/resources/help/contents/websocket.html
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> | ||
<HTML> | ||
<HEAD> | ||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"> | ||
<TITLE>gRPC WebSocket</TITLE> | ||
</HEAD> | ||
<BODY> | ||
<H1>gRPC WebSocket Support</H1> | ||
|
||
The gRPC WebSocket support feature enables the WebSocket add-on to decode and encode gRPC messages seamlessly. This integration allows users to inspect, modify, and manage gRPC communication over WebSockets. | ||
<h2>See also</h2> | ||
<table> | ||
<tr> | ||
<td> </td> | ||
<td><a href="grpc.html">gRPC</a></td> | ||
<td>for an overview of the gRPC add-on.</td> | ||
</tr> | ||
<tr> | ||
<td> </td> | ||
<td><a href="variant.html">gRPC Variant</a></td> | ||
<td>for information about the gRPC variant.</td> | ||
</tr> | ||
|
||
</table> | ||
|
||
</BODY> | ||
</HTML> |
This file contains 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
This file contains 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
This file contains 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
This file contains 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