public class AddOn extends Object
Modifier and Type | Class and Description |
---|---|
static class |
AddOn.AddOnRunRequirements
The requirements to run an
AddOn . |
static class |
AddOn.BaseRunRequirements |
static class |
AddOn.BundleData
The data of the bundle declared in the manifest of an add-on.
|
static class |
AddOn.ExtensionRunRequirements
The requirements to run an
extension (with add-on dependencies). |
static class |
AddOn.HelpSetData
The data to load a
HelpSet , declared in the manifest of an add-on. |
static class |
AddOn.InstallationStatus
The installation status of the add-on.
|
static class |
AddOn.InvalidAddOnException
An
IOException that indicates that a file is not a valid add-on. |
static class |
AddOn.Status |
static class |
AddOn.ValidationResult
The result of checking if a file is a valid add-on.
|
Modifier and Type | Field and Description |
---|---|
static String |
FILE_EXTENSION
The file extension of ZAP add-ons.
|
static String |
MANIFEST_FILE_NAME
The name of the manifest file, contained in the add-ons.
|
Constructor and Description |
---|
AddOn(File file)
Deprecated.
(2.6.0) Use
AddOn(Path) instead. |
AddOn(Path file)
Constructs an
AddOn from the given file . |
AddOn(String fileName)
Deprecated.
(2.6.0) Use
AddOn(Path) instead. |
AddOn(String id,
File baseDir,
org.apache.commons.configuration.SubnodeConfiguration xmlData)
Constructs an
AddOn from an add-on entry of ZapVersions.xml file. |
Modifier and Type | Method and Description |
---|---|
void |
addLoadedExtension(Extension extension)
Adds the given
extension to the list of loaded extensions of this add-on. |
AddOn.AddOnRunRequirements |
calculateExtensionInstallRequirements(Extension extension,
Collection<AddOn> availableAddOns)
Calculates the requirements to install/run the given
extension , same as calculateExtensionRunRequirements(Extension, Collection) but does not require the libraries
of the add-ons (this or dependencies) to exist in the file system. |
AddOn.AddOnRunRequirements |
calculateExtensionInstallRequirements(String classname,
Collection<AddOn> availableAddOns)
Calculates the requirements to install/run the given
extension , same as calculateExtensionRunRequirements(String, Collection) but does not require the libraries of
the add-ons (this or dependencies) to exist in the file system. |
AddOn.AddOnRunRequirements |
calculateExtensionRunRequirements(Extension extension,
Collection<AddOn> availableAddOns)
Calculates the requirements to run the given
extension , in the current ZAP and Java
versions and with the given availableAddOns . |
AddOn.AddOnRunRequirements |
calculateExtensionRunRequirements(String classname,
Collection<AddOn> availableAddOns)
Calculates the requirements to run the extension with the given
classname , in the
current ZAP and Java versions and with the given availableAddOns . |
AddOn.AddOnRunRequirements |
calculateInstallRequirements(Collection<AddOn> availableAddOns)
Calculates the requirements to install/run this add-on, same as
calculateRunRequirements(Collection) but does not require the libraries of the add-ons
(this or dependencies) to exist in the file system. |
AddOn.AddOnRunRequirements |
calculateRunRequirements(Collection<AddOn> availableAddOns)
Calculates the requirements to run this add-on, in the current ZAP and Java versions and with
the given
availableAddOns . |
boolean |
canLoad()
Deprecated.
(2.4.0) Use
calculateRunRequirements(Collection) instead. Returns false . |
boolean |
canLoadInCurrentVersion()
Tells whether or not this add-on can be loaded in the currently running ZAP version, as given
by
Constant.PROGRAM_VERSION . |
boolean |
canLoadInVersion(String zapVersion)
Tells whether or not this add-on can be loaded in the given
zapVersion . |
boolean |
canRunInCurrentJavaVersion()
Tells whether or not this add-on can be run in the currently running Java version.
|
boolean |
canRunInJavaVersion(String javaVersion)
Tells whether or not this add-on can be run in the given
javaVersion . |
static Optional<AddOn> |
createAddOn(Path file)
Convenience method that attempts to create an
AddOn from the given file. |
boolean |
dependsOn(AddOn addOn)
Tells whether or not this add-on has a (direct) dependency on the given
addOn
(including version). |
boolean |
dependsOn(Collection<AddOn> addOns)
Tells whether or not this add-on has a (direct) dependency on any of the given
addOns
(including version). |
boolean |
dependsOn(Extension extension,
AddOn addOn)
Tells whether or not the given
extension has a (direct) dependency on the given
addOn (including version). |
boolean |
equals(Object obj)
Two add-ons are considered equal if both add-ons have the same ID and version.
|
org.zaproxy.zap.control.AddOnClassnames |
getAddOnClassnames()
Gets the classnames that can be loaded for the add-on.
|
List<String> |
getAscanrules() |
String |
getAuthor() |
AddOn.BundleData |
getBundleData()
Gets the data of the bundle declared in the manifest.
|
String |
getChanges() |
ClassLoader |
getClassLoader()
Gets the class loader of the add-on.
|
String |
getDescription() |
org.zaproxy.zap.control.AddOnClassnames |
getExtensionAddOnClassnames(String classname)
Returns the classnames that can be loaded for the given
Extension (with
dependencies). |
List<String> |
getExtensions() |
List<String> |
getExtensionsWithDeps()
Returns the classnames of
Extension sthat have dependencies on add-ons. |
File |
getFile()
Gets the file of the add-on.
|
List<String> |
getFiles() |
int |
getFileVersion()
Deprecated.
(2.7.0) Use
getVersion() instead. |
String |
getHash() |
AddOn.HelpSetData |
getHelpSetData()
Gets the data for the HelpSet, declared in the manifest.
|
String |
getId() |
List<String> |
getIdsAddOnDependencies()
Returns the IDs of the add-ons dependencies, an empty collection if none.
|
URL |
getInfo() |
AddOn.InstallationStatus |
getInstallationStatus()
Gets installations status of the add-on.
|
List<AbstractPlugin> |
getLoadedAscanrules()
Gets the active scan rules of this add-on that were loaded.
|
List<Extension> |
getLoadedExtensions()
Gets the extensions of this add-on that were loaded.
|
List<Extension> |
getLoadedExtensionsWithDeps()
Gets the extensions of this add-on that have dependencies and were loaded.
|
List<PluginPassiveScanner> |
getLoadedPscanrules()
Gets the passive scan rules of this add-on that were loaded.
|
String |
getMinimumJavaVersion()
Returns the minimum Java version required to run this add-on or an empty
String if
there's no minimum version. |
String |
getName() |
String |
getNormalisedFileName()
Gets the normalised file name of the add-on.
|
String |
getNotBeforeVersion() |
String |
getNotFromVersion() |
List<String> |
getPscanrules() |
String |
getReleaseDate()
Gets the date when the add-on was released.
|
URL |
getRepo()
Gets the URL to the browsable repo.
|
ResourceBundle |
getResourceBundle()
Gets the resource bundle of the add-on.
|
long |
getSize() |
AddOn.Status |
getStatus() |
URL |
getUrl() |
Version |
getVersion()
Gets the semantic version of this add-on.
|
boolean |
hasExtensionsWithDeps()
Tells whether or not this add-on has at least one extension with dependencies.
|
int |
hashCode() |
boolean |
hasZapAddOnEntry() |
static boolean |
isAddOn(File f)
Deprecated.
(2.6.0) Use
isAddOn(Path) instead. |
static boolean |
isAddOn(Path file)
Tells whether or not the given file is a ZAP add-on.
|
static boolean |
isAddOn(String fileName)
Deprecated.
(2.6.0) Use
isAddOnFileName(String) instead, the checks done in this
method are more strict than it needs to. |
static boolean |
isAddOnFileName(String fileName)
Tells whether or not the given file name matches the name of a ZAP add-on.
|
boolean |
isExtensionLoaded(String classname)
Tells whether or not the extension with the given
classname is loaded. |
boolean |
isSameAddOn(AddOn addOn) |
boolean |
isUpdateTo(AddOn addOn) |
static AddOn.ValidationResult |
isValidAddOn(Path file)
Tells whether or not the given file is a ZAP add-on.
|
void |
removeLoadedExtension(Extension extension)
Removes the given
extension from the list of loaded extensions of this add-on. |
void |
setAuthor(String author) |
void |
setChanges(String changes) |
void |
setClassLoader(ClassLoader classLoader)
Sets the class loader of the add-on.
|
void |
setDescription(String description) |
void |
setFile(File file) |
void |
setId(String id) |
void |
setInfo(URL info) |
void |
setInstallationStatus(AddOn.InstallationStatus installationStatus)
Sets the installation status of the add-on.
|
void |
setName(String name) |
void |
setNotBeforeVersion(String notBeforeVersion) |
void |
setNotFromVersion(String notFromVersion) |
void |
setResourceBundle(ResourceBundle resourceBundle)
Sets the resource bundle of the add-on.
|
void |
setSize(long size) |
void |
setStatus(AddOn.Status status) |
void |
setUrl(URL url) |
String |
toString() |
public static final String MANIFEST_FILE_NAME
The manifest is expected to be in the root of the ZIP file.
public static final String FILE_EXTENSION
@Deprecated public AddOn(String fileName) throws Exception
AddOn(Path)
instead.AddOn
with the given file name.fileName
- the file name of the add-onException
- if the file name is not valid.@Deprecated public AddOn(File file) throws Exception
AddOn(Path)
instead.AddOn
from the given file
.
The "ZapAddOn.xml" ZIP file entry is read after validating that the add-on has a valid add-on file name.
The installation status of the add-on is 'not installed'.
file
- the file of the add-onException
- if the given file
does not exist, does not have a valid add-on file
name or an error occurred while reading the value #ZAP_ADD_ON_XML
ZIP file entrypublic AddOn(Path file) throws IOException
AddOn
from the given file
.
The "ZapAddOn.xml" ZIP file entry is read after validating that the add-on is a valid add-on.
The installation status of the add-on is 'not installed'.
file
- the file of the add-onAddOn.InvalidAddOnException
- (since 2.8.0) if the given file
does not exist, does
not have a valid add-on file name, or an error occurred while reading the add-on manifest
("ZapAddOn.xml").IOException
- if an error occurred while reading/validating the file.isAddOn(Path)
public AddOn(String id, File baseDir, org.apache.commons.configuration.SubnodeConfiguration xmlData) throws MalformedURLException, IOException
AddOn
from an add-on entry of ZapVersions.xml
file. The
installation status of the add-on is 'not installed'.
The given SubnodeConfiguration
must have a XPathExpressionEngine
installed.
The "ZapAddOn.xml" ZIP file entry is read, if the add-on file exists locally.
id
- the id of the add-onbaseDir
- the base directory where the add-on is locatedxmlData
- the source of add-on entry of ZapVersions.xml
fileMalformedURLException
- if the URL
of the add-on is malformedIOException
- if an error occurs while reading the XML dataXPathExpressionEngine
@Deprecated public static boolean isAddOn(String fileName)
isAddOnFileName(String)
instead, the checks done in this
method are more strict than it needs to.The file name must have the format "<id>-<status>-<version>.zap
". The id
is a string, the status
must be a value from AddOn.Status
and the version
must be an integer.
fileName
- the name of the file to checktrue
if the given file name is the name of an add-on, false
otherwise.isAddOnFileName(String)
public static boolean isAddOnFileName(String fileName)
The file name must have as file extension FILE_EXTENSION
.
fileName
- the name of the file to checktrue
if the given file name is the name of an add-on, false
otherwise.@Deprecated public static boolean isAddOn(File f)
isAddOn(Path)
instead.f
- the file to be checkedtrue
if the given file is an add-on, false
otherwise.public static boolean isAddOn(Path file)
An add-on is a ZIP file that contains, at least, a "ZapAddOn.xml" file.
file
- the file to be checkedtrue
if the given file is an add-on, false
otherwise.isAddOnFileName(String)
,
isValidAddOn(Path)
public static AddOn.ValidationResult isValidAddOn(Path file)
file
- the file to be checked.isAddOn(Path)
public static Optional<AddOn> createAddOn(Path file)
AddOn
from the given file.
A warning is logged if the add-on is invalid and an error if an error occurred while creating it.
file
- the file of the add-on.AddOn
, or empty if not valid or an error occurred while
creating it.public String getId()
public void setId(String id)
public String getName()
public void setName(String name)
public String getDescription()
public void setDescription(String description)
@Deprecated public int getFileVersion()
getVersion()
instead.public Version getVersion()
Since 2.7.0, for add-ons that use just an integer as the version it's appended ".0.0", for example, for version 14 it returns the version 14.0.0.
null
.public AddOn.Status getStatus()
public void setStatus(AddOn.Status status)
public String getChanges()
public void setChanges(String changes)
public String getNormalisedFileName()
Should be used when copying the file from an "unknown" source (e.g. manually installed).
getFile()
public File getFile()
getNormalisedFileName()
public void setFile(File file)
public URL getUrl()
public void setUrl(URL url)
public long getSize()
public void setSize(long size)
public String getAuthor()
public void setAuthor(String author)
public ClassLoader getClassLoader()
null
if the add-on is not installed.public void setClassLoader(ClassLoader classLoader)
Note: This method should be called only by bootstrap classes.
classLoader
- the class loader of the add-on, might be null
.public void setInstallationStatus(AddOn.InstallationStatus installationStatus)
installationStatus
- the new installation statusIllegalArgumentException
- if the given installationStatus
is null
.public AddOn.InstallationStatus getInstallationStatus()
null
public boolean hasZapAddOnEntry()
public org.zaproxy.zap.control.AddOnClassnames getAddOnClassnames()
public List<String> getExtensionsWithDeps()
Extension
sthat have dependencies on add-ons.hasExtensionsWithDeps()
public org.zaproxy.zap.control.AddOnClassnames getExtensionAddOnClassnames(String classname)
Extension
(with
dependencies).classname
- the classname of the extensionhasExtensionsWithDeps()
public boolean hasExtensionsWithDeps()
true
if the add-on has at leas one extension with dependencies, false
otherwisegetExtensionsWithDeps()
public List<Extension> getLoadedExtensionsWithDeps()
List
with the extensions of this add-on that have
dependencies and were loadedpublic List<Extension> getLoadedExtensions()
List
with the extensions of this add-on that were loadedpublic void addLoadedExtension(Extension extension)
extension
to the list of loaded extensions of this add-on.
This add-on is set to the given extension
.
extension
- the extension of this add-on that was loadedIllegalArgumentException
- if extension is null
removeLoadedExtension(Extension)
,
Extension.setAddOn(AddOn)
public void removeLoadedExtension(Extension extension)
extension
from the list of loaded extensions of this add-on.
The add-on of the given extension
is set to null
.
The call to this method has no effect if the given extension
does not belong to
this add-on.
extension
- the loaded extension of this add-on that should be removedIllegalArgumentException
- if extension is null
addLoadedExtension(Extension)
,
Extension.setAddOn(AddOn)
public List<AbstractPlugin> getLoadedAscanrules()
List
with the active scan rules of this add-on that were
loaded, never null
setLoadedAscanrules(List)
public List<PluginPassiveScanner> getLoadedPscanrules()
List
with the passive scan rules of this add-on that were
loaded, never null
setLoadedPscanrules(List)
public boolean isSameAddOn(AddOn addOn)
public boolean isUpdateTo(AddOn addOn) throws IllegalArgumentException
IllegalArgumentException
@Deprecated public boolean canLoad()
calculateRunRequirements(Collection)
instead. Returns false
.false
always.public boolean canLoadInCurrentVersion()
Constant.PROGRAM_VERSION
.true
if the add-on can be loaded in the currently running ZAP version, false
otherwisecanLoadInVersion(String)
,
Constant.PROGRAM_VERSION
public boolean canRunInCurrentJavaVersion()
This is a convenience method that calls canRunInJavaVersion(String)
with the
running Java version (as given by SystemUtils.JAVA_VERSION
) as parameter.
true
if the add-on can be run in the currently running Java version, false
otherwisecanRunInJavaVersion(String)
,
SystemUtils.JAVA_VERSION
public boolean canRunInJavaVersion(String javaVersion)
javaVersion
.
If the given javaVersion
is null
and this add-on depends on a specific
java version the method returns false
.
javaVersion
- the java version that will be checkedtrue
if the add-on can be loaded in the given javaVersion
, false
otherwisepublic AddOn.AddOnRunRequirements calculateRunRequirements(Collection<AddOn> availableAddOns)
availableAddOns
.
If the add-on depends on other add-ons, those add-ons are also checked if are also runnable.
Note: All the given availableAddOns
are expected to be loadable
in the currently running ZAP version, that is, the method AddOn.canLoadInCurrentVersion()
, returns true
.
availableAddOns
- the other add-ons availablecanLoadInCurrentVersion()
,
canRunInCurrentJavaVersion()
,
AddOn.AddOnRunRequirements
public AddOn.AddOnRunRequirements calculateInstallRequirements(Collection<AddOn> availableAddOns)
calculateRunRequirements(Collection)
but does not require the libraries of the add-ons
(this or dependencies) to exist in the file system.availableAddOns
- the other add-ons available.calculateRunRequirements(Collection)
,
AddOn.AddOnRunRequirements
public AddOn.AddOnRunRequirements calculateExtensionRunRequirements(Extension extension, Collection<AddOn> availableAddOns)
extension
, in the current ZAP and Java
versions and with the given availableAddOns
.
If the extension depends on other add-ons, those add-ons are checked if are also runnable.
Note: All the given availableAddOns
are expected to be loadable
in the currently running ZAP version, that is, the method AddOn.canLoadInCurrentVersion()
, returns true
.
extension
- the extension that will be checkedavailableAddOns
- the add-ons availableAddOn.AddOnRunRequirements.getExtensionRequirements()
public AddOn.AddOnRunRequirements calculateExtensionInstallRequirements(Extension extension, Collection<AddOn> availableAddOns)
extension
, same as calculateExtensionRunRequirements(Extension, Collection)
but does not require the libraries
of the add-ons (this or dependencies) to exist in the file system.extension
- the extension that will be checked.availableAddOns
- the add-ons available.AddOn.AddOnRunRequirements.getExtensionRequirements()
public AddOn.AddOnRunRequirements calculateExtensionRunRequirements(String classname, Collection<AddOn> availableAddOns)
classname
, in the
current ZAP and Java versions and with the given availableAddOns
.
If the extension depends on other add-ons, those add-ons are checked if are also runnable.
Note: All the given availableAddOns
are expected to be loadable
in the currently running ZAP version, that is, the method AddOn.canLoadInCurrentVersion()
, returns true
.
classname
- the classname of extension that will be checkedavailableAddOns
- the add-ons availableAddOn.AddOnRunRequirements.getExtensionRequirements()
public AddOn.AddOnRunRequirements calculateExtensionInstallRequirements(String classname, Collection<AddOn> availableAddOns)
extension
, same as calculateExtensionRunRequirements(String, Collection)
but does not require the libraries of
the add-ons (this or dependencies) to exist in the file system.classname
- the classname of extension that will be checked.availableAddOns
- the add-ons available.AddOn.AddOnRunRequirements.getExtensionRequirements()
public boolean dependsOn(Extension extension, AddOn addOn)
extension
has a (direct) dependency on the given
addOn
(including version).extension
- the extension that will be checkedaddOn
- the add-on that will be checked in the dependencies on the extensiontrue
if the extension depends on the given add-on, false
otherwise.public boolean isExtensionLoaded(String classname)
classname
is loaded.classname
- the classname of the extensiontrue
if the extension is loaded, false
otherwisepublic String getMinimumJavaVersion()
String
if
there's no minimum version.String
if no
minimum versionpublic boolean canLoadInVersion(String zapVersion)
zapVersion
.zapVersion
- the ZAP version that will be checkedtrue
if the add-on can be loaded in the given zapVersion
, false
otherwisepublic void setNotBeforeVersion(String notBeforeVersion)
public void setNotFromVersion(String notFromVersion)
public String getNotBeforeVersion()
public String getNotFromVersion()
public URL getInfo()
public void setInfo(URL info)
public URL getRepo()
null
.public String getHash()
public String getReleaseDate()
The date has the format YYYY-MM-DD
.
Note: The date is only available for add-ons created from the marketplace.
null
if not available.public AddOn.BundleData getBundleData()
null
.getResourceBundle()
public ResourceBundle getResourceBundle()
null
if none.public void setResourceBundle(ResourceBundle resourceBundle)
Note: This method should be called only by bootstrap classes.
resourceBundle
- the resource bundle of the add-on, might be null
.getBundleData()
public AddOn.HelpSetData getHelpSetData()
null
.public List<String> getIdsAddOnDependencies()
public boolean dependsOn(AddOn addOn)
addOn
(including version).addOn
- the add-on that will be checkedtrue
if it depends on the given add-on, false
otherwise.public boolean dependsOn(Collection<AddOn> addOns)
addOns
(including version).addOns
- the add-ons that will be checkedtrue
if it depends on any of the given add-ons, false
otherwise.