Package org.zaproxy.zap.extension.ascan
Class ExtensionActiveScan
- java.lang.Object
-
- org.parosproxy.paros.extension.ExtensionAdaptor
-
- org.zaproxy.zap.extension.ascan.ExtensionActiveScan
-
- All Implemented Interfaces:
CommandLineListener
,Extension
,SessionChangedListener
,ScanController<ActiveScan>
public class ExtensionActiveScan extends ExtensionAdaptor implements SessionChangedListener, CommandLineListener, ScanController<ActiveScan>
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
NAME
static int
PROXY_LISTENER_ORDER
static java.lang.String
SCRIPT_TYPE_ACTIVE
static java.lang.String
SCRIPT_TYPE_VARIANT
-
Constructor Summary
Constructors Constructor Description ExtensionActiveScan()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCustomScanPanel(CustomScanPanel panel)
void
addPolicyPanel(AbstractParamPanel panel)
void
destroy()
Performs final cleanups, free resources.void
execute(CommandLineArgument[] args)
Execute the command line using the argument provided.java.util.List<java.lang.String>
getActiveActions()
Returns the (internationalised) names of all active actions of the extension - if there are any the user will be given the option not to exit ZAP or, if the extension is bundled in an add-on that's being updated or uninstalled, not to continue with the changes.java.util.List<ActiveScan>
getActiveScans()
java.util.List<ActiveScan>
getAllScans()
int
getAttackModeStackSize()
java.lang.String
getAuthor()
Gets the author of the extension.java.util.List<java.lang.Class<? extends Extension>>
getDependencies()
Gets the list ofExtension
s that this extension depends on.java.lang.String
getDescription()
Returns the description of the extension, to be shown in UI components.java.util.List<java.lang.String>
getExcludeList()
Gets the exclude list.java.util.List<java.lang.String>
getHandledExtensions()
Get the list of extensions this listener can handleActiveScan
getLastScan()
PolicyManager
getPolicyManager()
ActiveScan
getScan(int id)
protected ScannerParam
getScannerParam()
This method initializes scannerParamjava.lang.String
getUIName()
By default returns the name returned bygetName()
.boolean
handleFile(java.io.File file)
Handle the specified file (in whatever way is appropriate).void
hook(ExtensionHook extensionHook)
Called during extension's initialisation to allow to add new functionality to core components.boolean
isPanelSwitch()
Returns true if the GUI will switch to the Active Scan panel when a scan is started.void
pauseAllScans()
void
pauseScan(int id)
void
postInit()
Implement this method to perform tasks after all extensions/add-ons have been initialised.int
registerScan(ActiveScan scanner)
int
removeAllScans()
void
removeCustomScanPanel(CustomScanPanel panel)
int
removeFinishedScans()
ActiveScan
removeScan(int id)
void
resumeAllScans()
void
resumeScan(int id)
void
sessionAboutToChange(Session session)
Called just prior to the session changing.void
sessionChanged(Session session)
Called just after the session has changed.void
sessionModeChanged(Control.Mode mode)
Called when the user changes the mode.void
sessionScopeChanged(Session session)
Called when the user has changes the session scope.void
setExcludeList(java.util.List<java.lang.String> urls)
Sets the exclude list.void
setPanelSwitch(boolean panelSwitch)
Sets if the GUI will switch to the Active Scan panel when a scan is started.void
showCustomScanDialog(SiteNode node)
void
showCustomScanDialog(Target target)
Shows the active scan dialogue with the given target, if not already visible.protected void
showPolicyDialog(PolicyManagerDialog parent)
protected void
showPolicyDialog(PolicyManagerDialog parent, java.lang.String name)
void
showPolicyManagerDialog()
int
startScan(java.lang.String name, Target target, User user, java.lang.Object[] contextSpecificObjects)
int
startScan(SiteNode startNode)
Start the scanning process beginning to a specific nodeint
startScan(Target target)
int
startScan(Target target, User user, java.lang.Object[] contextSpecificObjects)
void
startScanAllInScope()
int
startScanNode(SiteNode startNode)
void
stopAllScans()
void
stopScan(int id)
boolean
supportsDb(java.lang.String type)
Part of the core set of features that should be supported by all db typesboolean
supportsLowMemory()
Return true it the extension can run with the 'low memory' option.-
Methods inherited from class org.parosproxy.paros.extension.ExtensionAdaptor
canUnload, databaseOpen, getAddOn, getExtensionMenu, getExtensionView, getI18nPrefix, getMessages, getModel, getName, getOrder, getUnsavedResources, getView, hasView, init, initModel, initView, initXML, isCore, isDepreciated, isEnabled, optionsLoaded, postInstall, setAddOn, setDescription, setEnabled, setI18nPrefix, setMessages, setName, setOrder, start, stop, unload
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.parosproxy.paros.extension.CommandLineListener
preExecute
-
Methods inherited from interface org.parosproxy.paros.extension.Extension
getURL, getVersion
-
Methods inherited from interface org.parosproxy.paros.extension.SessionChangedListener
sessionPropertiesChanged
-
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
SCRIPT_TYPE_ACTIVE
public static final java.lang.String SCRIPT_TYPE_ACTIVE
- See Also:
- Constant Field Values
-
SCRIPT_TYPE_VARIANT
public static final java.lang.String SCRIPT_TYPE_VARIANT
- See Also:
- Constant Field Values
-
PROXY_LISTENER_ORDER
public static final int PROXY_LISTENER_ORDER
- See Also:
- Constant Field Values
-
-
Method Detail
-
getUIName
public java.lang.String getUIName()
Description copied from class:ExtensionAdaptor
By default returns the name returned bygetName()
.- Specified by:
getUIName
in interfaceExtension
- Overrides:
getUIName
in classExtensionAdaptor
- Returns:
- the UI name of the extension, never
null
- See Also:
ExtensionAdaptor.getName()
-
postInit
public void postInit()
Description copied from interface:Extension
Implement this method to perform tasks after all extensions/add-ons have been initialised.- Specified by:
postInit
in interfaceExtension
- Overrides:
postInit
in classExtensionAdaptor
- See Also:
Extension.postInstall()
-
hook
public void hook(ExtensionHook extensionHook)
Description copied from interface:Extension
Called during extension's initialisation to allow to add new functionality to core components.- Specified by:
hook
in interfaceExtension
- Overrides:
hook
in classExtensionAdaptor
- Parameters:
extensionHook
- the hook to add the components.
-
getActiveActions
public java.util.List<java.lang.String> getActiveActions()
Description copied from interface:Extension
Returns the (internationalised) names of all active actions of the extension - if there are any the user will be given the option not to exit ZAP or, if the extension is bundled in an add-on that's being updated or uninstalled, not to continue with the changes.An active action is something that's started by the user, for example, a scan.
- Specified by:
getActiveActions
in interfaceExtension
- Overrides:
getActiveActions
in classExtensionAdaptor
- Returns:
- a
List
containing the active actions ornull
if none - See Also:
Extension.getUnsavedResources()
-
startScanAllInScope
public void startScanAllInScope()
-
startScan
public int startScan(SiteNode startNode)
Start the scanning process beginning to a specific node- Parameters:
startNode
- the start node where the scanning should begin to work- Returns:
- the ID of the scan
-
startScanNode
public int startScanNode(SiteNode startNode)
-
startScan
public int startScan(Target target)
-
startScan
public int startScan(Target target, User user, java.lang.Object[] contextSpecificObjects)
-
startScan
public int startScan(java.lang.String name, Target target, User user, java.lang.Object[] contextSpecificObjects)
- Specified by:
startScan
in interfaceScanController<ActiveScan>
-
isPanelSwitch
public boolean isPanelSwitch()
Returns true if the GUI will switch to the Active Scan panel when a scan is started.- Since:
- 2.11.0
-
setPanelSwitch
public void setPanelSwitch(boolean panelSwitch)
Sets if the GUI will switch to the Active Scan panel when a scan is started. Code should only set this to false just before starting a scan and reset it to true as soon as the scan has started.- Since:
- 2.11.0
-
showPolicyDialog
protected void showPolicyDialog(PolicyManagerDialog parent) throws org.apache.commons.configuration.ConfigurationException
- Throws:
org.apache.commons.configuration.ConfigurationException
-
showPolicyDialog
protected void showPolicyDialog(PolicyManagerDialog parent, java.lang.String name) throws org.apache.commons.configuration.ConfigurationException
- Throws:
org.apache.commons.configuration.ConfigurationException
-
sessionChanged
public void sessionChanged(Session session)
Description copied from interface:SessionChangedListener
Called just after the session has changed. sessionChanged may be called by non-event thread. Should handle with care in all the listener. Use EventThread for each GUI event.- Specified by:
sessionChanged
in interfaceSessionChangedListener
- Parameters:
session
- the new session
-
getScannerParam
protected ScannerParam getScannerParam()
This method initializes scannerParam- Returns:
- org.parosproxy.paros.core.scanner.ScannerParam
-
execute
public void execute(CommandLineArgument[] args)
Description copied from interface:CommandLineListener
Execute the command line using the argument provided.- Specified by:
execute
in interfaceCommandLineListener
- Parameters:
args
- the command line arguments
-
setExcludeList
public void setExcludeList(java.util.List<java.lang.String> urls)
Sets the exclude list.- Parameters:
urls
- the new exclude list
-
getExcludeList
public java.util.List<java.lang.String> getExcludeList()
Gets the exclude list.- Returns:
- the exclude list
-
addPolicyPanel
public void addPolicyPanel(AbstractParamPanel panel)
-
getDependencies
public java.util.List<java.lang.Class<? extends Extension>> getDependencies()
Description copied from interface:Extension
Gets the list ofExtension
s that this extension depends on.- Specified by:
getDependencies
in interfaceExtension
- Overrides:
getDependencies
in classExtensionAdaptor
- Returns:
- the list of dependencies, empty (or
null
) if none.
-
sessionAboutToChange
public void sessionAboutToChange(Session session)
Description copied from interface:SessionChangedListener
Called just prior to the session changing. Listeners should close down any resources associated with this session. sessionAboutToChange may be called by non-event thread. Should handle with care in all the listener. Use EventThread for each GUI event.- Specified by:
sessionAboutToChange
in interfaceSessionChangedListener
- Parameters:
session
- the session about to be closed
-
getAuthor
public java.lang.String getAuthor()
Description copied from interface:Extension
Gets the author of the extension.Since 2.9.0 defaults to the author of the add-on, if set, otherwise an empty string.
-
getDescription
public java.lang.String getDescription()
Description copied from interface:Extension
Returns the description of the extension, to be shown in UI components. The description must be internationalised.- Specified by:
getDescription
in interfaceExtension
- Overrides:
getDescription
in classExtensionAdaptor
- Returns:
- the description of the extension, never
null
-
sessionScopeChanged
public void sessionScopeChanged(Session session)
Description copied from interface:SessionChangedListener
Called when the user has changes the session scope. sessionScopeChanged may be called by non-event thread. Should handle with care in all the listener. Use EventThread for each GUI event.- Specified by:
sessionScopeChanged
in interfaceSessionChangedListener
- Parameters:
session
- the current session
-
sessionModeChanged
public void sessionModeChanged(Control.Mode mode)
Description copied from interface:SessionChangedListener
Called when the user changes the mode. sessionModeChanged may be called by non-event thread. Should handle with care in all the listener. Use EventThread for each GUI event.- Specified by:
sessionModeChanged
in interfaceSessionChangedListener
- Parameters:
mode
- the new mode
-
destroy
public void destroy()
Description copied from interface:Extension
Performs final cleanups, free resources.Called when the extension is removed (i.e. corresponding add-on is uninstalled) and when ZAP shuts down.
Called after
stopping
the extension.Should be called only by core functionality.
- Specified by:
destroy
in interfaceExtension
- Overrides:
destroy
in classExtensionAdaptor
-
showCustomScanDialog
public void showCustomScanDialog(SiteNode node)
-
showCustomScanDialog
public void showCustomScanDialog(Target target)
Shows the active scan dialogue with the given target, if not already visible.- Parameters:
target
- the target, might benull
.- Since:
- 2.8.0.
-
addCustomScanPanel
public void addCustomScanPanel(CustomScanPanel panel)
-
removeCustomScanPanel
public void removeCustomScanPanel(CustomScanPanel panel)
-
showPolicyManagerDialog
public void showPolicyManagerDialog()
-
handleFile
public boolean handleFile(java.io.File file)
Description copied from interface:CommandLineListener
Handle the specified file (in whatever way is appropriate). This will only be called for files specified on the command line without switches and which match one of the extensions returned by getHandledExtensions()- Specified by:
handleFile
in interfaceCommandLineListener
- Parameters:
file
- the file provided through the command line- Returns:
- true if the listener handled the file, false otherwise
-
getHandledExtensions
public java.util.List<java.lang.String> getHandledExtensions()
Description copied from interface:CommandLineListener
Get the list of extensions this listener can handle- Specified by:
getHandledExtensions
in interfaceCommandLineListener
- Returns:
- a
List
with the handled extensions
-
getAllScans
public java.util.List<ActiveScan> getAllScans()
- Specified by:
getAllScans
in interfaceScanController<ActiveScan>
-
getActiveScans
public java.util.List<ActiveScan> getActiveScans()
- Specified by:
getActiveScans
in interfaceScanController<ActiveScan>
-
getScan
public ActiveScan getScan(int id)
- Specified by:
getScan
in interfaceScanController<ActiveScan>
-
stopScan
public void stopScan(int id)
- Specified by:
stopScan
in interfaceScanController<ActiveScan>
-
pauseScan
public void pauseScan(int id)
- Specified by:
pauseScan
in interfaceScanController<ActiveScan>
-
resumeScan
public void resumeScan(int id)
- Specified by:
resumeScan
in interfaceScanController<ActiveScan>
-
stopAllScans
public void stopAllScans()
- Specified by:
stopAllScans
in interfaceScanController<ActiveScan>
-
pauseAllScans
public void pauseAllScans()
- Specified by:
pauseAllScans
in interfaceScanController<ActiveScan>
-
resumeAllScans
public void resumeAllScans()
- Specified by:
resumeAllScans
in interfaceScanController<ActiveScan>
-
removeScan
public ActiveScan removeScan(int id)
- Specified by:
removeScan
in interfaceScanController<ActiveScan>
-
removeAllScans
public int removeAllScans()
- Specified by:
removeAllScans
in interfaceScanController<ActiveScan>
-
removeFinishedScans
public int removeFinishedScans()
- Specified by:
removeFinishedScans
in interfaceScanController<ActiveScan>
-
getLastScan
public ActiveScan getLastScan()
- Specified by:
getLastScan
in interfaceScanController<ActiveScan>
-
registerScan
public int registerScan(ActiveScan scanner)
-
getPolicyManager
public PolicyManager getPolicyManager()
-
getAttackModeStackSize
public int getAttackModeStackSize()
-
supportsLowMemory
public boolean supportsLowMemory()
Description copied from interface:Extension
Return true it the extension can run with the 'low memory' option. If the low memory option is set (and the extension supports it) then code should minimize the data stored in memory, using the db for all significant data. Extensions that do not support the low memory option will not be run if the option is set.- Specified by:
supportsLowMemory
in interfaceExtension
- Overrides:
supportsLowMemory
in classExtensionAdaptor
- Returns:
true
if the extension support the 'low memory' option,false
otherwise
-
supportsDb
public boolean supportsDb(java.lang.String type)
Part of the core set of features that should be supported by all db types- Specified by:
supportsDb
in interfaceExtension
- Overrides:
supportsDb
in classExtensionAdaptor
- Parameters:
type
- the db type- Returns:
- true if the specified db type is supported by the extension (or if it doesn't use any db)
- See Also:
Database.getType()
-
-