-
-
Notifications
You must be signed in to change notification settings - Fork 713
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
graphql: Add tech detection for GraphQL Engines
- CHANGELOG > Added note. - build file > Added dependency. - GraphQlFingerprinter > Updated to add Technology matches when GraphQL engines are fingerprinted. - GraphQlFingerprinterUnitTest > Updated for new handling. - DiscoveredGraphQlEngineHandler > An interface to be implemented for consumption/handling of discovered GraphQL engines. - ExtensionTechDetection > Added to facilitate optional dependence. - ExtensionTechDetectionUnitTest > Tests :) - Messages.properties > Added key/value pairs to support the optional dependency. - alert.html > Added note about the new functionality. Signed-off-by: kingthorin <kingthorin@users.noreply.github.com>
- Loading branch information
1 parent
a1f83eb
commit 03a0902
Showing
11 changed files
with
325 additions
and
28 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
27 changes: 27 additions & 0 deletions
27
addOns/graphql/src/main/java/org/zaproxy/addon/graphql/DiscoveredGraphQlEngineHandler.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,27 @@ | ||
/* | ||
* 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.graphql; | ||
|
||
import org.zaproxy.addon.graphql.GraphQlFingerprinter.DiscoveredGraphQlEngine; | ||
|
||
public interface DiscoveredGraphQlEngineHandler { | ||
|
||
void process(DiscoveredGraphQlEngine engine); | ||
} |
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
101 changes: 101 additions & 0 deletions
101
.../src/main/java/org/zaproxy/addon/graphql/techdetection/ExtensionTechDetectionGraphQl.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,101 @@ | ||
/* | ||
* 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.graphql.techdetection; | ||
|
||
import java.util.List; | ||
import org.parosproxy.paros.Constant; | ||
import org.parosproxy.paros.control.Control; | ||
import org.parosproxy.paros.extension.Extension; | ||
import org.parosproxy.paros.extension.ExtensionAdaptor; | ||
import org.parosproxy.paros.extension.ExtensionHook; | ||
import org.zaproxy.addon.graphql.GraphQlFingerprinter; | ||
import org.zaproxy.addon.graphql.GraphQlFingerprinter.DiscoveredGraphQlEngine; | ||
import org.zaproxy.zap.extension.wappalyzer.Application; | ||
import org.zaproxy.zap.extension.wappalyzer.ApplicationMatch; | ||
import org.zaproxy.zap.extension.wappalyzer.ExtensionWappalyzer; | ||
|
||
public class ExtensionTechDetectionGraphQl extends ExtensionAdaptor { | ||
|
||
public static final String NAME = "ExtensionTechDetectionGraphQl"; | ||
|
||
private static final List<Class<? extends Extension>> DEPENDENCIES = | ||
List.of(ExtensionWappalyzer.class); | ||
|
||
private static ExtensionWappalyzer extTech; | ||
|
||
public ExtensionTechDetectionGraphQl() { | ||
super(NAME); | ||
} | ||
|
||
@Override | ||
public String getUIName() { | ||
return Constant.messages.getString("graphql.techdetection.name"); | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return Constant.messages.getString("graphql.techdetection.desc"); | ||
} | ||
|
||
@Override | ||
public List<Class<? extends Extension>> getDependencies() { | ||
return DEPENDENCIES; | ||
} | ||
|
||
@Override | ||
public void hook(ExtensionHook extensionHook) { | ||
super.hook(extensionHook); | ||
GraphQlFingerprinter.addEngineHandler(ExtensionTechDetectionGraphQl::addApp); | ||
} | ||
|
||
@Override | ||
public boolean canUnload() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void unload() { | ||
GraphQlFingerprinter.resetHandlers(); | ||
} | ||
|
||
private static ApplicationMatch getAppForEngine(DiscoveredGraphQlEngine engine) { | ||
Application gqlEngine = new Application(); | ||
gqlEngine.setName(engine.getName()); | ||
gqlEngine.setCategories(List.of("GraphQL Engine")); | ||
gqlEngine.setWebsite(engine.getDocsUrl()); | ||
gqlEngine.setImplies(List.of(engine.getTechnologies())); | ||
|
||
return new ApplicationMatch(gqlEngine); | ||
} | ||
|
||
private static void addApp(DiscoveredGraphQlEngine engine) { | ||
getExtTech().addApplicationsToSite(engine.getUri(), getAppForEngine(engine)); | ||
} | ||
|
||
private static ExtensionWappalyzer getExtTech() { | ||
if (extTech == null) { | ||
extTech = | ||
Control.getSingleton() | ||
.getExtensionLoader() | ||
.getExtension(ExtensionWappalyzer.class); | ||
} | ||
return extTech; | ||
} | ||
} |
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
Oops, something went wrong.