idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
20,600
public String getString ( Object value ) { try { return DATE_TIME_FORMAT . format ( value ) ; } catch ( IllegalArgumentException ignore ) { } return StringValues . TO_STRING . getString ( value ) ; }
This method is not threadsafe and should therefore only be called from the EDT
20,601
private ApiResponse buildResponseFromContext ( Context c ) { Map < String , String > fields = new HashMap < > ( ) ; fields . put ( "name" , c . getName ( ) ) ; fields . put ( "id" , Integer . toString ( c . getIndex ( ) ) ) ; fields . put ( "description" , c . getDescription ( ) ) ; fields . put ( "inScope" , Boolean . toString ( c . isInScope ( ) ) ) ; fields . put ( "excludeRegexs" , jsonEncodeList ( c . getExcludeFromContextRegexs ( ) ) ) ; fields . put ( "includeRegexs" , jsonEncodeList ( c . getIncludeInContextRegexs ( ) ) ) ; AuthenticationMethod authenticationMethod = c . getAuthenticationMethod ( ) ; if ( authenticationMethod != null ) { Pattern pattern = authenticationMethod . getLoggedInIndicatorPattern ( ) ; fields . put ( "loggedInPattern" , pattern == null ? "" : pattern . toString ( ) ) ; pattern = authenticationMethod . getLoggedOutIndicatorPattern ( ) ; fields . put ( "loggedOutPattern" , pattern == null ? "" : pattern . toString ( ) ) ; AuthenticationMethodType type = authenticationMethod . getType ( ) ; fields . put ( "authType" , type == null ? "" : type . getName ( ) ) ; } AuthorizationDetectionMethod authorizationDetectionMethod = c . getAuthorizationDetectionMethod ( ) ; if ( authorizationDetectionMethod != null ) { fields . put ( "authenticationDetectionMethodId" , String . valueOf ( authorizationDetectionMethod . getMethodUniqueIdentifier ( ) ) ) ; } fields . put ( "urlParameterParserClass" , c . getUrlParamParser ( ) . getClass ( ) . getCanonicalName ( ) ) ; fields . put ( "urlParameterParserConfig" , c . getUrlParamParser ( ) . getConfig ( ) ) ; fields . put ( "postParameterParserClass" , c . getPostParamParser ( ) . getClass ( ) . getCanonicalName ( ) ) ; fields . put ( "postParameterParserConfig" , c . getPostParamParser ( ) . getConfig ( ) ) ; return new ApiResponseSet < String > ( "context" , fields ) ; }
Builds the response describing an Context .
20,602
private Tech getTech ( String techName ) throws ApiException { String trimmedTechName = techName . trim ( ) ; for ( Tech tech : Tech . builtInTech ) { if ( tech . toString ( ) . equalsIgnoreCase ( trimmedTechName ) ) return tech ; } throw new ApiException ( Type . ILLEGAL_PARAMETER , "The tech '" + trimmedTechName + "' does not exist" ) ; }
Gets the tech that matches the techName or throws an exception if no tech matches
20,603
private JButton getStartSessionButton ( ) { if ( startSessionButton == null ) { startSessionButton = new JButton ( ) ; startSessionButton . setText ( Constant . messages . getString ( "database.newsession.button.start" ) ) ; startSessionButton . setEnabled ( false ) ; startSessionButton . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent e ) { PersistSessionDialog . this . dispose ( ) ; } } ) ; } return startSessionButton ; }
This method initializes startSessionButton
20,604
public synchronized HttpMessage pollPath ( HttpMessage msg ) { SiteNode resultNode = null ; URI uri = msg . getRequestHeader ( ) . getURI ( ) ; SiteNode parent = getRoot ( ) ; String folder ; try { String host = getHostName ( uri ) ; parent = findChild ( parent , host ) ; if ( parent == null ) { return null ; } List < String > path = model . getSession ( ) . getTreePath ( uri ) ; if ( path . size ( ) == 0 ) { resultNode = parent ; } for ( int i = 0 ; i < path . size ( ) ; i ++ ) { folder = path . get ( i ) ; if ( folder != null && ! folder . equals ( "" ) ) { if ( i == path . size ( ) - 1 ) { String leafName = getLeafName ( folder , msg ) ; resultNode = findChild ( parent , leafName ) ; } else { parent = findChild ( parent , folder ) ; if ( parent == null ) { return null ; } } } } } catch ( URIException e ) { log . error ( e . getMessage ( ) , e ) ; } if ( resultNode == null || resultNode . getHistoryReference ( ) == null ) { return null ; } HttpMessage nodeMsg = null ; try { nodeMsg = resultNode . getHistoryReference ( ) . getHttpMessage ( ) ; } catch ( Exception e ) { log . error ( e . getMessage ( ) , e ) ; } return nodeMsg ; }
Return the a HttpMessage of the same type under the tree path .
20,605
public synchronized SiteNode addPath ( HistoryReference ref ) { if ( Constant . isLowMemoryOptionSet ( ) ) { throw new InvalidParameterException ( "SiteMap should not be accessed when the low memory option is set" ) ; } HttpMessage msg = null ; try { msg = ref . getHttpMessage ( ) ; } catch ( Exception e ) { log . error ( e . getMessage ( ) , e ) ; return null ; } return addPath ( ref , msg ) ; }
Add the HistoryReference into the SiteMap . This method will rely on reading message from the History table . Note that this method must only be called on the EventDispatchThread
20,606
public void setFilter ( SiteTreeFilter filter ) { this . filter = filter ; SiteNode root = getRoot ( ) ; setFilter ( filter , root ) ; root . setFiltered ( false ) ; }
Set the filter for the sites tree
20,607
private void clearParentFilter ( SiteNode parent ) { if ( parent != null ) { parent . setFiltered ( false ) ; clearParentFilter ( parent . getParent ( ) ) ; } }
Recurse up the tree setting all of the parent nodes to unfiltered
20,608
private void handleEvent ( SiteNode parent , SiteNode node , EventType eventType ) { switch ( eventType ) { case ADD : publishEvent ( SiteMapEventPublisher . SITE_NODE_ADDED_EVENT , node ) ; if ( parent == getRoot ( ) ) { publishEvent ( SiteMapEventPublisher . SITE_ADDED_EVENT , node ) ; } break ; case REMOVE : publishEvent ( SiteMapEventPublisher . SITE_NODE_REMOVED_EVENT , node ) ; if ( parent == getRoot ( ) ) { publishEvent ( SiteMapEventPublisher . SITE_REMOVED_EVENT , node ) ; } } }
Handles the publishing of the add or remove event . Node events are always published . Site events are only published when the parent of the node is the root of the tree .
20,609
private static void publishEvent ( String event , SiteNode node ) { ZAP . getEventBus ( ) . publishSyncEvent ( SiteMapEventPublisher . getPublisher ( ) , new Event ( SiteMapEventPublisher . getPublisher ( ) , event , new Target ( node ) ) ) ; }
Publish the event being carried out .
20,610
public void reloadPolicies ( String scanPolicyName ) { DefaultComboBoxModel < String > policies = new DefaultComboBoxModel < > ( ) ; for ( String policy : extension . getPolicyManager ( ) . getAllPolicyNames ( ) ) { policies . addElement ( policy ) ; } getPolicySelector ( ) . setModel ( policies ) ; getPolicySelector ( ) . setSelectedItem ( scanPolicyName ) ; }
Reloads the scan policies which will pick any new ones that have been defined and selects the policy with the given name .
20,611
private ZapTextArea getTxtDescription ( ) { if ( txtDescription == null ) { txtDescription = new ZapTextArea ( ) ; txtDescription . setBorder ( javax . swing . BorderFactory . createBevelBorder ( javax . swing . border . BevelBorder . LOWERED ) ) ; txtDescription . setLineWrap ( true ) ; } return txtDescription ; }
This method initializes txtDescription
20,612
public void save ( ) { List < Object > contextSpecificObjects = new ArrayList < Object > ( ) ; techTreeState = getTechTree ( ) . getTechSet ( ) ; if ( ! this . getBoolValue ( FIELD_ADVANCED ) ) { contextSpecificObjects . add ( scanPolicy ) ; } else { contextSpecificObjects . add ( policyPanel . getScanPolicy ( ) ) ; if ( target == null && this . customPanels != null ) { for ( CustomScanPanel customPanel : this . customPanels ) { target = customPanel . getTarget ( ) ; if ( target != null ) { break ; } } } getVariantPanel ( ) . saveParam ( scannerParam ) ; if ( getDisableNonCustomVectors ( ) . isSelected ( ) ) { scannerParam . setTargetParamsInjectable ( 0 ) ; scannerParam . setTargetParamsEnabledRPC ( 0 ) ; } if ( ! getBoolValue ( FIELD_RECURSE ) && injectionPointModel . getSize ( ) > 0 ) { int [ ] [ ] injPoints = new int [ injectionPointModel . getSize ( ) ] [ ] ; for ( int i = 0 ; i < injectionPointModel . getSize ( ) ; i ++ ) { Highlight hl = injectionPointModel . elementAt ( i ) ; injPoints [ i ] = new int [ 2 ] ; injPoints [ i ] [ 0 ] = hl . getStartOffset ( ) ; injPoints [ i ] [ 1 ] = hl . getEndOffset ( ) ; } try { if ( target != null && target . getStartNode ( ) != null ) { VariantUserDefined . setInjectionPoints ( this . target . getStartNode ( ) . getHistoryReference ( ) . getURI ( ) . toString ( ) , injPoints ) ; enableUserDefinedRPC ( ) ; } } catch ( Exception e ) { logger . error ( e . getMessage ( ) , e ) ; } } scannerParam . setHostPerScan ( extension . getScannerParam ( ) . getHostPerScan ( ) ) ; scannerParam . setThreadPerHost ( extension . getScannerParam ( ) . getThreadPerHost ( ) ) ; scannerParam . setHandleAntiCSRFTokens ( extension . getScannerParam ( ) . getHandleAntiCSRFTokens ( ) ) ; scannerParam . setMaxResultsToList ( extension . getScannerParam ( ) . getMaxResultsToList ( ) ) ; contextSpecificObjects . add ( scannerParam ) ; contextSpecificObjects . add ( techTreeState ) ; if ( this . customPanels != null ) { for ( CustomScanPanel customPanel : this . customPanels ) { Object [ ] objs = customPanel . getContextSpecificObjects ( ) ; if ( objs != null ) { for ( Object obj : objs ) { contextSpecificObjects . add ( obj ) ; } } } } } target . setRecurse ( this . getBoolValue ( FIELD_RECURSE ) ) ; if ( target . getContext ( ) == null && getSelectedContext ( ) != null ) { target . setContext ( getSelectedContext ( ) ) ; } this . extension . startScan ( target , getSelectedUser ( ) , contextSpecificObjects . toArray ( ) ) ; }
Use the save method to launch a scan
20,613
public void enableUserDefinedRPC ( ) { int enabledRpc = scannerParam . getTargetParamsEnabledRPC ( ) ; enabledRpc |= ScannerParam . RPC_USERDEF ; scannerParam . setTargetParamsEnabledRPC ( enabledRpc ) ; }
Force UserDefinedRPC setting
20,614
protected void initializeCredentialsConfigPanel ( ) { AuthenticationMethodType type = workingContext . getAuthenticationMethod ( ) . getType ( ) ; if ( type . hasCredentialsOptionsPanel ( ) ) { credentialsPanel = type . buildCredentialsOptionsPanel ( configuredCredentials , workingContext ) ; fieldsPanel . add ( credentialsPanel , LayoutHelper . getGBC ( 0 , 3 , 2 , 1 , new Insets ( 4 , 8 , 2 , 4 ) ) ) ; fieldsPanel . revalidate ( ) ; this . pack ( ) ; } }
Initialize credentials config panel .
20,615
private JToolBar getToolbarLeft ( ) { if ( footerToolbarLeft == null ) { footerToolbarLeft = new JToolBar ( ) ; footerToolbarLeft . setEnabled ( true ) ; footerToolbarLeft . setFloatable ( false ) ; footerToolbarLeft . setRollover ( true ) ; footerToolbarLeft . setName ( "Footer Toolbar Left" ) ; footerToolbarLeft . setBorder ( BorderFactory . createEmptyBorder ( ) ) ; } return footerToolbarLeft ; }
Left toolbar for alerts
20,616
private JToolBar getToolbarRight ( ) { if ( footerToolbarRight == null ) { footerToolbarRight = new JToolBar ( ) ; footerToolbarRight . setEnabled ( true ) ; footerToolbarRight . setFloatable ( false ) ; footerToolbarRight . setRollover ( true ) ; footerToolbarRight . setName ( "Footer Toolbar Right" ) ; footerToolbarRight . setBorder ( BorderFactory . createEmptyBorder ( ) ) ; } return footerToolbarRight ; }
Right toolbar for current scan results
20,617
public void addFooterToolbarRightLabel ( JLabel label ) { DisplayUtils . scaleIcon ( label ) ; this . footerToolbarRight . add ( label ) ; this . validate ( ) ; }
Support for dynamic scanning results in the footer
20,618
protected ExtensionHttpSessions getExtensionHttpSessions ( ) { if ( extensionHttpSessions == null ) { extensionHttpSessions = Control . getSingleton ( ) . getExtensionLoader ( ) . getExtension ( ExtensionHttpSessions . class ) ; if ( extensionHttpSessions == null ) log . error ( "Http Sessions Extension should be enabled for the " + ExtensionUserManagement . class . getSimpleName ( ) + " to work." ) ; } return extensionHttpSessions ; }
Gets the ExtensionHttpSessions if it s enabled .
20,619
private ContextUsersPanel getContextPanel ( int contextId ) { ContextUsersPanel panel = this . userPanelsMap . get ( contextId ) ; if ( panel == null ) { panel = new ContextUsersPanel ( this , contextId ) ; this . userPanelsMap . put ( contextId , panel ) ; } return panel ; }
Gets the context panel for a given context .
20,620
public ContextUserAuthManager getContextUserAuthManager ( int contextId ) { ContextUserAuthManager manager = contextManagers . get ( contextId ) ; if ( manager == null ) { manager = new ContextUserAuthManager ( contextId ) ; contextManagers . put ( contextId , manager ) ; } return manager ; }
Gets the context user auth manager for a given context .
20,621
public List < User > getUIConfiguredUsers ( int contextId ) { ContextUsersPanel panel = this . userPanelsMap . get ( contextId ) ; if ( panel != null ) { return Collections . unmodifiableList ( panel . getUsersTableModel ( ) . getUsers ( ) ) ; } return null ; }
Gets an unmodifiable view of the users that are currently shown in the UI .
20,622
public UsersTableModel getUIConfiguredUsersModel ( int contextId ) { ContextUsersPanel panel = this . userPanelsMap . get ( contextId ) ; if ( panel != null ) { return panel . getUsersTableModel ( ) ; } return null ; }
Gets the model of the users that are currently shown in the UI .
20,623
public static FindDialog getDialog ( Window parent , boolean modal ) { if ( parent == null ) { throw new IllegalArgumentException ( "The parent must not be null." ) ; } FindDialog activeDialog = getParentsMap ( ) . get ( parent ) ; if ( activeDialog != null ) { activeDialog . getTxtFind ( ) . requestFocus ( ) ; return activeDialog ; } FindDialog newDialog = new FindDialog ( parent , modal ) ; getParentsMap ( ) . put ( parent , newDialog ) ; newDialog . addWindowListener ( new WindowAdapter ( ) { public void windowClosed ( WindowEvent e ) { getParentsMap ( ) . remove ( parent ) ; } } ) ; return newDialog ; }
Get the FindDialog for the parent if there is one or creates and returns a new one .
20,624
private JButton getBtnFind ( ) { if ( btnFind == null ) { btnFind = new JButton ( ) ; btnFind . setText ( Constant . messages . getString ( "edit.find.button.find" ) ) ; btnFind . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent e ) { find ( ) ; } } ) ; } return btnFind ; }
This method initializes btnFind
20,625
private void highlightAll ( ) { HighlighterManager highlighter = HighlighterManager . getInstance ( ) ; LinkedList < HighlightSearchEntry > highlights = highlighter . getHighlights ( ) ; for ( HighlightSearchEntry entry : highlights ) { highlightEntryParser ( entry ) ; } }
Highlight all search strings from HighlightManager
20,626
private void highlightEntryParser ( HighlightSearchEntry entry ) { String text ; int lastPos = 0 ; text = this . getText ( ) ; Highlighter hilite = this . getHighlighter ( ) ; HighlightPainter painter = new DefaultHighlighter . DefaultHighlightPainter ( entry . getColor ( ) ) ; while ( ( lastPos = text . indexOf ( entry . getToken ( ) , lastPos ) ) > - 1 ) { try { hilite . addHighlight ( lastPos , lastPos + entry . getToken ( ) . length ( ) , painter ) ; lastPos += entry . getToken ( ) . length ( ) ; } catch ( BadLocationException e ) { log . warn ( "Could not highlight entry" , e ) ; } } }
Highlight all found strings
20,627
public void setSelectedInternalItem ( User user ) { User internalUser = null ; int index = getIndexOf ( user ) ; if ( index != - 1 ) { internalUser = getElementAt ( index ) ; } else if ( getSize ( ) > 0 ) { internalUser = getElementAt ( 0 ) ; } setSelectedItemImpl ( internalUser ) ; }
Sets the selected item as the actual internal item with the same id as the provided user .
20,628
public int getIndexOf ( Object object ) { int index = tableModel . getUsers ( ) . indexOf ( object ) ; if ( index < 0 && customUsers != null ) return tableModel . getUsers ( ) . size ( ) + ArrayUtils . indexOf ( customUsers , object ) ; return index ; }
Returns the index of the specified element in the model s item list .
20,629
public void setMessage ( HttpMessage msg ) { try { if ( script != null ) { script . parseParameters ( this , msg ) ; } } catch ( Exception e ) { extension . handleScriptException ( wrapper , e ) ; } }
Set the current message that this Variant has to scan
20,630
public String getParamName ( int index ) { return ( index < params . size ( ) ) ? params . get ( index ) . getName ( ) : null ; }
Support method to get back the name of the n - th parameter
20,631
public String getParamValue ( int index ) { return ( index < params . size ( ) ) ? params . get ( index ) . getValue ( ) : null ; }
Support method to get back the value of the n - th parameter
20,632
public void addParam ( String name , String value , int type ) { params . add ( new NameValuePair ( type , name , value , params . size ( ) ) ) ; }
Support method to add a new param to this custom variant
20,633
public void addParamQuery ( String name , String value ) { addParam ( name , value , NameValuePair . TYPE_QUERY_STRING ) ; }
Support method to add a new QueryString param to this custom variant
20,634
public void addParamPost ( String name , String value ) { addParam ( name , value , NameValuePair . TYPE_POST_DATA ) ; }
Support method to add a new PostData param to this custom variant
20,635
public void addParamHeader ( String name , String value ) { addParam ( name , value , NameValuePair . TYPE_HEADER ) ; }
Support method to add a new Header param to this custom variant
20,636
private String setParameter ( HttpMessage msg , NameValuePair originalPair , String paramName , String value , boolean escaped ) { try { if ( script != null ) { currentParam = originalPair ; script . setParameter ( this , msg , paramName , value , escaped ) ; } } catch ( Exception e ) { extension . handleScriptException ( wrapper , e ) ; } finally { currentParam = null ; } return value ; }
Inner method for correct scripting
20,637
private JButton getBtnAccept ( ) { if ( btnAccept == null ) { btnAccept = new JButton ( ) ; btnAccept . setText ( "Accept" ) ; btnAccept . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent e ) { accepted = true ; LicenseFrame . this . dispose ( ) ; } } ) ; } return btnAccept ; }
This method initializes btnAccept
20,638
private JButton getBtnDecline ( ) { if ( btnDecline == null ) { btnDecline = new JButton ( ) ; btnDecline . setText ( "Decline" ) ; btnDecline . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent e ) { accepted = false ; System . exit ( 1 ) ; } } ) ; } return btnDecline ; }
This method initializes btnDecline
20,639
public boolean matches ( String versionRange ) throws IllegalArgumentException { Validate . notEmpty ( versionRange , "Parameter versionRange must not be null nor empty." ) ; try { return impl . satisfies ( versionRange ) ; } catch ( com . github . zafarkhaja . semver . ParseException e ) { throw new IllegalArgumentException ( "Parameter versionRange [" + versionRange + "] is not valid: " + e . getMessage ( ) ) ; } }
Tells whether or not the given version range matches this version .
20,640
public static boolean isValidVersionRange ( String versionRange ) { try { ExpressionParser . newInstance ( ) . parse ( versionRange ) ; return true ; } catch ( com . github . zafarkhaja . semver . ParseException ignore ) { } return false ; }
Tells whether or not the given version range is valid .
20,641
public char getChar ( String key ) { try { String str = this . getStringImpl ( key ) ; if ( str . length ( ) > 0 ) { return str . charAt ( 0 ) ; } } catch ( Exception e ) { } return '\u0000' ; }
Returns the specified char from the language file . As these are typically used for mnemonics the null char is returned if the key is not defined
20,642
public static int getIntParam ( JSONObject params , String paramName ) throws ApiException { if ( ! params . containsKey ( paramName ) ) { throw new ApiException ( ApiException . Type . MISSING_PARAMETER , paramName ) ; } try { return params . getInt ( paramName ) ; } catch ( JSONException e ) { throw new ApiException ( ApiException . Type . ILLEGAL_PARAMETER , paramName , e ) ; } }
Gets the int param with a given name and throws an exception accordingly if not found or valid .
20,643
public static boolean getBooleanParam ( JSONObject params , String paramName ) throws ApiException { if ( ! params . containsKey ( paramName ) ) { throw new ApiException ( ApiException . Type . MISSING_PARAMETER , paramName ) ; } try { return params . getBoolean ( paramName ) ; } catch ( JSONException e ) { throw new ApiException ( ApiException . Type . ILLEGAL_PARAMETER , paramName , e ) ; } }
Gets a boolean from the parameter with the given name .
20,644
public static String getOptionalStringParam ( JSONObject params , String paramName ) { if ( params . containsKey ( paramName ) ) { return params . getString ( paramName ) ; } return null ; }
Gets an optional string param returning null if the parameter was not found .
20,645
public static String getNonEmptyStringParam ( JSONObject params , String paramName ) throws ApiException { if ( ! params . containsKey ( paramName ) ) { throw new ApiException ( Type . MISSING_PARAMETER , paramName ) ; } String value = params . getString ( paramName ) ; if ( value == null || value . isEmpty ( ) ) { throw new ApiException ( Type . MISSING_PARAMETER , paramName ) ; } return value ; }
Gets the non empty string param with a given name and throws an exception accordingly if not found or empty .
20,646
private void initialize ( ) { this . setText ( Constant . messages . getString ( "sites.resend.popup" ) ) ; this . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent evt ) { if ( treeSite != null ) { SiteNode node = ( SiteNode ) treeSite . getLastSelectedPathComponent ( ) ; ManualRequestEditorDialog dialog = extension . getResendDialog ( ) ; HistoryReference ref = node . getHistoryReference ( ) ; HttpMessage msg = null ; try { msg = ref . getHttpMessage ( ) . cloneRequest ( ) ; dialog . setMessage ( msg ) ; dialog . setVisible ( true ) ; } catch ( HttpMalformedHeaderException | DatabaseException e ) { logger . error ( e . getMessage ( ) , e ) ; } } } } ) ; }
This method initialises this
20,647
private JButton getBtnApply ( ) { if ( btnApply == null ) { btnApply = new JButton ( ) ; btnApply . setText ( Constant . messages . getString ( "history.filter.button.apply" ) ) ; btnApply . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent e ) { try { filter . setMethods ( methodList . getSelectedValuesList ( ) ) ; filter . setCodes ( codeList . getSelectedValuesList ( ) ) ; filter . setTags ( tagList . getSelectedValuesList ( ) ) ; filter . setRisks ( riskList . getSelectedValuesList ( ) ) ; filter . setReliabilities ( confidenceList . getSelectedValuesList ( ) ) ; filter . setNote ( notesComboBox . getSelectedItem ( ) ) ; filter . setUrlIncPatternList ( strToRegexList ( regexInc . getText ( ) ) ) ; filter . setUrlExcPatternList ( strToRegexList ( regexExc . getText ( ) ) ) ; exitResult = JOptionPane . OK_OPTION ; HistoryFilterPlusDialog . this . dispose ( ) ; } catch ( PatternSyntaxException e1 ) { View . getSingleton ( ) . showWarningDialog ( Constant . messages . getString ( "history.filter.badregex.warning" , e1 . getMessage ( ) ) ) ; } } } ) ; } return btnApply ; }
This method initializes btnApply
20,648
private JButton getBtnReset ( ) { if ( btnReset == null ) { btnReset = new JButton ( ) ; btnReset . setText ( Constant . messages . getString ( "history.filter.button.clear" ) ) ; btnReset . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent e ) { exitResult = JOptionPane . NO_OPTION ; methodList . setSelectedIndices ( new int [ 0 ] ) ; codeList . setSelectedIndices ( new int [ 0 ] ) ; tagList . setSelectedIndices ( new int [ 0 ] ) ; riskList . setSelectedIndices ( new int [ 0 ] ) ; confidenceList . setSelectedIndices ( new int [ 0 ] ) ; notesComboBox . setSelectedItem ( HistoryFilter . NOTES_IGNORE ) ; regexInc . setText ( "" ) ; regexExc . setText ( "" ) ; filter . reset ( ) ; } } ) ; } return btnReset ; }
This method initializes btnReset
20,649
public void run ( ) { log . debug ( "HostProcess.run" ) ; try { hostProcessStartTime = System . currentTimeMillis ( ) ; pluginFactory . reset ( ) ; synchronized ( mapPluginStats ) { for ( Plugin plugin : pluginFactory . getPending ( ) ) { mapPluginStats . put ( plugin . getId ( ) , new PluginStats ( plugin . getName ( ) ) ) ; } } for ( StructuralNode startNode : startNodes ) { traverse ( startNode , true , node -> { if ( canScanNode ( node ) ) { messagesIdsToAppScan . add ( node . getHistoryReference ( ) . getHistoryId ( ) ) ; } } ) ; getAnalyser ( ) . start ( startNode ) ; } nodeInScopeCount = messagesIdsToAppScan . size ( ) ; if ( ! messagesIdsToAppScan . isEmpty ( ) ) { messageIdToHostScan = messagesIdsToAppScan . get ( 0 ) ; } logScanInfo ( ) ; Plugin plugin ; while ( ! isStop ( ) && pluginFactory . existPluginToRun ( ) ) { checkPause ( ) ; if ( isStop ( ) ) { break ; } plugin = pluginFactory . nextPlugin ( ) ; if ( plugin != null ) { plugin . setDelayInMs ( this . scannerParam . getDelayInMs ( ) ) ; plugin . setTechSet ( this . techSet ) ; processPlugin ( plugin ) ; } else { Util . sleep ( 1000 ) ; } } threadPool . waitAllThreadComplete ( 300000 ) ; } catch ( Exception e ) { log . error ( "An error occurred while active scanning:" , e ) ; stop ( ) ; } finally { notifyHostProgress ( null ) ; notifyHostComplete ( ) ; getHttpSender ( ) . shutdown ( ) ; } }
Main execution method
20,650
public boolean isStop ( ) { if ( this . scannerParam . getMaxScanDurationInMins ( ) > 0 ) { if ( System . currentTimeMillis ( ) - this . hostProcessStartTime > TimeUnit . MINUTES . toMillis ( this . scannerParam . getMaxScanDurationInMins ( ) ) ) { this . stopReason = Constant . messages . getString ( "ascan.progress.label.skipped.reason.maxScan" ) ; this . stop ( ) ; } } return ( isStop || parentScanner . isStop ( ) ) ; }
Check if the current host scan has been stopped
20,651
HttpRequestConfig getRedirectRequestConfig ( ) { if ( redirectRequestConfig == null ) { redirectRequestConfig = HttpRequestConfig . builder ( ) . setRedirectionValidator ( getRedirectionValidator ( ) ) . build ( ) ; } return redirectRequestConfig ; }
Gets the HTTP request configuration that ensures the followed redirections are in scan s scope .
20,652
HttpRedirectionValidator getRedirectionValidator ( ) { if ( redirectionValidator == null ) { redirectionValidator = redirection -> { if ( ! nodeInScope ( redirection . getEscapedURI ( ) ) ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Skipping redirection out of scan's scope: " + redirection ) ; } return false ; } return true ; } ; } return redirectionValidator ; }
Gets the redirection validator that ensures the followed redirections are in scan s scope .
20,653
public String getSkippedReason ( Plugin plugin ) { PluginStats pluginStats = mapPluginStats . get ( plugin . getId ( ) ) ; if ( pluginStats == null ) { return stopReason ; } return pluginStats . getSkippedReason ( ) ; }
Gets the reason why the given plugin was skipped .
20,654
void pluginCompleted ( Plugin plugin ) { PluginStats pluginStats = mapPluginStats . get ( plugin . getId ( ) ) ; if ( pluginStats == null ) { return ; } StringBuilder sb = new StringBuilder ( ) ; if ( isStop ( ) ) { sb . append ( "stopped host/plugin " ) ; } else if ( pluginStats . isSkipped ( ) ) { sb . append ( "skipped plugin " ) ; String reason = pluginStats . getSkippedReason ( ) ; if ( reason != null ) { sb . append ( '[' ) . append ( reason ) . append ( "] " ) ; } } else { sb . append ( "completed host/plugin " ) ; } sb . append ( hostAndPort ) . append ( " | " ) . append ( plugin . getCodeName ( ) ) ; long startTimeMillis = pluginStats . getStartTime ( ) ; long diffTimeMillis = System . currentTimeMillis ( ) - startTimeMillis ; String diffTimeString = decimalFormat . format ( diffTimeMillis / 1000.0 ) ; sb . append ( " in " ) . append ( diffTimeString ) . append ( 's' ) ; sb . append ( " with " ) . append ( pluginStats . getMessageCount ( ) ) . append ( " message(s) sent" ) ; sb . append ( " and " ) . append ( pluginStats . getAlertCount ( ) ) . append ( " alert(s) raised." ) ; log . info ( sb . toString ( ) ) ; pluginFactory . setRunningPluginCompleted ( plugin ) ; notifyHostProgress ( null ) ; pluginStats . setProgress ( nodeInScopeCount ) ; }
Complete the current plugin and update statistics
20,655
public void setUser ( User user ) { this . user = user ; if ( httpSender != null ) { httpSender . setUser ( user ) ; } }
Set the user to scan as . If null then the current session will be used .
20,656
public int getPluginRequestCount ( int pluginId ) { PluginStats pluginStats = mapPluginStats . get ( pluginId ) ; if ( pluginStats != null ) { return pluginStats . getMessageCount ( ) ; } return 0 ; }
Gets the request count of the plugin with the given ID .
20,657
private void addPanelForContext ( Context context , ContextPanelFactory contextPanelFactory , String [ ] panelPath ) { AbstractContextPropertiesPanel panel = contextPanelFactory . getContextPanel ( context ) ; panel . setSessionDialog ( getSessionDialog ( ) ) ; getSessionDialog ( ) . addParamPanel ( panelPath , panel , false ) ; this . contextPanels . add ( panel ) ; List < AbstractContextPropertiesPanel > panels = contextPanelFactoriesPanels . get ( contextPanelFactory ) ; if ( panels == null ) { panels = new ArrayList < > ( ) ; contextPanelFactoriesPanels . put ( contextPanelFactory , panels ) ; } panels . add ( panel ) ; }
Adds a custom context panel for the given context created form the given context panel factory and placed under the given path .
20,658
private void parseArray ( String fieldName ) { int chr ; int idx = 0 ; while ( true ) { sr . skipWhitespaceRead ( ) ; sr . unreadLastCharacter ( ) ; parseValue ( fieldName + "[" + ( idx ++ ) + "]" ) ; chr = sr . skipWhitespaceRead ( ) ; if ( chr == END_ARRAY ) { break ; } if ( chr != VALUE_SEPARATOR ) { throw new IllegalArgumentException ( "Expected ',' or ']' inside array at position " + sr . getPosition ( ) ) ; } } }
Read a JSON array
20,659
public void addScanResult ( String uri , String method , String flags , boolean skipped ) { SpiderScanResult result = new SpiderScanResult ( uri , method , flags , ! skipped ) ; scanResults . add ( result ) ; fireTableRowsInserted ( scanResults . size ( ) - 1 , scanResults . size ( ) - 1 ) ; }
Adds a new spider scan result . Method is synchronized internally .
20,660
public static void mergeNodeChildren ( TreeNode node ) { DefaultMutableTreeNode masterNode = ( DefaultMutableTreeNode ) node ; for ( int i = 0 ; i < masterNode . getChildCount ( ) ; i ++ ) { DefaultMutableTreeNode child = ( DefaultMutableTreeNode ) masterNode . getChildAt ( i ) ; if ( ! child . isLeaf ( ) ) { MergeHelpUtilities . mergeNodeChildren ( DEFAULT_MERGE_TYPE , child ) ; } } }
this class instead .
20,661
private javax . swing . JPanel getPanelCommand ( ) { if ( panelCommand == null ) { panelCommand = new javax . swing . JPanel ( ) ; panelCommand . setLayout ( new java . awt . GridBagLayout ( ) ) ; panelCommand . setName ( "Search Panel" ) ; GridBagConstraints gridBagConstraints1 = new GridBagConstraints ( ) ; GridBagConstraints gridBagConstraints2 = new GridBagConstraints ( ) ; gridBagConstraints1 . gridx = 0 ; gridBagConstraints1 . gridy = 0 ; gridBagConstraints1 . weightx = 1.0D ; gridBagConstraints1 . insets = new java . awt . Insets ( 2 , 2 , 2 , 2 ) ; gridBagConstraints1 . fill = java . awt . GridBagConstraints . HORIZONTAL ; gridBagConstraints1 . anchor = java . awt . GridBagConstraints . NORTHWEST ; gridBagConstraints2 . gridx = 0 ; gridBagConstraints2 . gridy = 1 ; gridBagConstraints2 . weightx = 1.0 ; gridBagConstraints2 . weighty = 1.0 ; gridBagConstraints2 . insets = new java . awt . Insets ( 0 , 0 , 0 , 0 ) ; gridBagConstraints2 . fill = java . awt . GridBagConstraints . BOTH ; gridBagConstraints2 . anchor = java . awt . GridBagConstraints . NORTHWEST ; panelCommand . add ( this . getPanelToolbar ( ) , gridBagConstraints1 ) ; panelCommand . add ( getJScrollPane ( ) , gridBagConstraints2 ) ; } return panelCommand ; }
This method initializes panelCommand
20,662
public void setMessage ( String data , boolean isSecure ) throws HttpMalformedHeaderException { super . setMessage ( data ) ; try { parse ( isSecure ) ; } catch ( HttpMalformedHeaderException e ) { mMalformedHeader = true ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Malformed header: " + data , e ) ; } throw e ; } catch ( Exception e ) { log . error ( "Failed to parse:\n" + data , e ) ; mMalformedHeader = true ; throw new HttpMalformedHeaderException ( e . getMessage ( ) ) ; } }
Set this request header with the given message .
20,663
public void setURI ( URI uri ) throws URIException { if ( uri . getScheme ( ) == null || uri . getScheme ( ) . equals ( "" ) ) { mUri = new URI ( HTTP + "://" + getHeader ( HOST ) + "/" + mUri . toString ( ) , true ) ; } else { mUri = uri ; } if ( uri . getScheme ( ) . equalsIgnoreCase ( HTTPS ) ) { mIsSecure = true ; } else { mIsSecure = false ; } setHostPort ( mUri . getPort ( ) ) ; }
Sets the URI of this request header .
20,664
public void setSecure ( boolean isSecure ) throws URIException { mIsSecure = isSecure ; if ( mUri == null ) { return ; } URI newUri = mUri ; if ( isSecure ( ) && mUri . getScheme ( ) . equalsIgnoreCase ( HTTP ) ) { newUri = new URI ( mUri . toString ( ) . replaceFirst ( HTTP , HTTPS ) , true ) ; } else if ( ! isSecure ( ) && mUri . getScheme ( ) . equalsIgnoreCase ( HTTPS ) ) { newUri = new URI ( mUri . toString ( ) . replaceFirst ( HTTPS , HTTP ) , true ) ; } if ( newUri != mUri ) { mUri = newUri ; setHostPort ( mUri . getPort ( ) ) ; } }
Sets whether or not the request is done using a secure scheme HTTPS .
20,665
private void parse ( boolean isSecure ) throws URIException , HttpMalformedHeaderException { mIsSecure = isSecure ; Matcher matcher = patternRequestLine . matcher ( mStartLine ) ; if ( ! matcher . find ( ) ) { mMalformedHeader = true ; throw new HttpMalformedHeaderException ( "Failed to find pattern " + patternRequestLine + " in: " + mStartLine ) ; } mMethod = matcher . group ( 1 ) ; String sUri = matcher . group ( 2 ) ; mVersion = matcher . group ( 3 ) ; if ( ! mVersion . equalsIgnoreCase ( HTTP09 ) && ! mVersion . equalsIgnoreCase ( HTTP10 ) && ! mVersion . equalsIgnoreCase ( HTTP11 ) ) { mMalformedHeader = true ; throw new HttpMalformedHeaderException ( "Unexpected version: " + mVersion ) ; } if ( mMethod . equalsIgnoreCase ( CONNECT ) ) { parseHostName ( sUri ) ; mUri = parseURI ( mHostName ) ; } else { mUri = parseURI ( sUri ) ; if ( mUri . getScheme ( ) == null || mUri . getScheme ( ) . equals ( "" ) ) { mUri = new URI ( HTTP + "://" + getHeader ( HOST ) + mUri . toString ( ) , true ) ; } if ( isSecure ( ) && mUri . getScheme ( ) . equalsIgnoreCase ( HTTP ) ) { mUri = new URI ( mUri . toString ( ) . replaceFirst ( HTTP , HTTPS ) , true ) ; } if ( mUri . getScheme ( ) . equalsIgnoreCase ( HTTPS ) ) { setSecure ( true ) ; } mHostName = mUri . getHost ( ) ; setHostPort ( mUri . getPort ( ) ) ; } }
Parse this request header .
20,666
public String getHostName ( ) { String hostName = mHostName ; try { hostName = ( ( mUri . getHost ( ) != null ) ? mUri . getHost ( ) : mHostName ) ; } catch ( URIException e ) { if ( log . isDebugEnabled ( ) ) { log . warn ( e ) ; } } return hostName ; }
Get the host name in this request header .
20,667
public boolean isImage ( ) { if ( getURI ( ) == null ) { return false ; } try { final String path = getURI ( ) . getPath ( ) ; if ( path != null ) { return ( patternImage . matcher ( path ) . find ( ) ) ; } } catch ( URIException e ) { log . error ( e . getMessage ( ) , e ) ; } return false ; }
Return if this request header is a image request basing on the path suffix .
20,668
public void setGetParams ( TreeSet < HtmlParameter > getParams ) { if ( mUri == null ) { return ; } if ( getParams . isEmpty ( ) ) { try { mUri . setQuery ( "" ) ; } catch ( URIException e ) { log . error ( e . getMessage ( ) , e ) ; } return ; } StringBuilder sbQuery = new StringBuilder ( ) ; for ( HtmlParameter parameter : getParams ) { if ( parameter . getType ( ) != HtmlParameter . Type . url ) { continue ; } sbQuery . append ( parameter . getName ( ) ) ; sbQuery . append ( '=' ) ; sbQuery . append ( parameter . getValue ( ) ) ; sbQuery . append ( '&' ) ; } if ( sbQuery . length ( ) <= 2 ) { try { mUri . setQuery ( "" ) ; } catch ( URIException e ) { log . error ( e . getMessage ( ) , e ) ; } return ; } String query = sbQuery . substring ( 0 , sbQuery . length ( ) - 1 ) ; try { mUri . setQuery ( query ) ; } catch ( URIException e ) { log . error ( e . getMessage ( ) , e ) ; } }
Based on getParams
20,669
public void setCookieParams ( TreeSet < HtmlParameter > cookieParams ) { if ( cookieParams . isEmpty ( ) ) { setHeader ( HttpHeader . COOKIE , null ) ; } StringBuilder sbData = new StringBuilder ( ) ; for ( HtmlParameter parameter : cookieParams ) { if ( parameter . getType ( ) != HtmlParameter . Type . cookie ) { continue ; } String cookieName = parameter . getName ( ) ; if ( ! cookieName . isEmpty ( ) ) { sbData . append ( cookieName ) ; sbData . append ( '=' ) ; } sbData . append ( parameter . getValue ( ) ) ; sbData . append ( "; " ) ; } if ( sbData . length ( ) <= 2 ) { setHeader ( HttpHeader . COOKIE , null ) ; return ; } final String data = sbData . substring ( 0 , sbData . length ( ) - 2 ) ; setHeader ( HttpHeader . COOKIE , data ) ; }
based on cookieParams
20,670
public List < HttpCookie > getHttpCookies ( ) { List < HttpCookie > cookies = new LinkedList < > ( ) ; TreeSet < HtmlParameter > ts = getCookieParams ( ) ; Iterator < HtmlParameter > it = ts . iterator ( ) ; while ( it . hasNext ( ) ) { HtmlParameter htmlParameter = it . next ( ) ; if ( ! htmlParameter . getName ( ) . isEmpty ( ) ) { try { cookies . add ( new HttpCookie ( htmlParameter . getName ( ) , htmlParameter . getValue ( ) ) ) ; } catch ( IllegalArgumentException e ) { log . debug ( e . getMessage ( ) + " " + htmlParameter . getName ( ) ) ; } } } return cookies ; }
Gets a list of the http cookies from this request Header .
20,671
private JButton getBtnDelete ( ) { if ( btnDelete == null ) { btnDelete = new JButton ( ) ; btnDelete . setText ( Constant . messages . getString ( "history.managetags.button.delete" ) ) ; btnDelete . setMinimumSize ( new java . awt . Dimension ( 75 , 30 ) ) ; btnDelete . setPreferredSize ( new java . awt . Dimension ( 75 , 30 ) ) ; btnDelete . setMaximumSize ( new java . awt . Dimension ( 100 , 40 ) ) ; btnDelete . setEnabled ( true ) ; btnDelete . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent e ) { deleteTags ( tagList . getSelectedValuesList ( ) ) ; } } ) ; } return btnDelete ; }
This method initializes btnDelete
20,672
private void fetchResource ( HttpMessage msg ) throws IOException { if ( parent . getHttpSender ( ) == null ) { return ; } try { parent . getHttpSender ( ) . sendAndReceive ( msg ) ; } catch ( ConnectException e ) { log . debug ( "Failed to connect to: " + msg . getRequestHeader ( ) . getURI ( ) , e ) ; throw e ; } catch ( SocketTimeoutException e ) { log . debug ( "Socket timeout: " + msg . getRequestHeader ( ) . getURI ( ) , e ) ; throw e ; } catch ( SocketException e ) { log . debug ( "Socket exception: " + msg . getRequestHeader ( ) . getURI ( ) , e ) ; throw e ; } catch ( UnknownHostException e ) { log . debug ( "Unknown host: " + msg . getRequestHeader ( ) . getURI ( ) , e ) ; throw e ; } catch ( Exception e ) { log . error ( "An error occurred while fetching the resource [" + msg . getRequestHeader ( ) . getURI ( ) + "]: " + e . getMessage ( ) , e ) ; throw e ; } }
Fetches a resource .
20,673
private ZapMenuItem getMenuItemCheckUpdate ( ) { if ( menuItemCheckUpdate == null ) { menuItemCheckUpdate = new ZapMenuItem ( "cfu.help.menu.check" , getView ( ) . getMenuShortcutKeyStroke ( KeyEvent . VK_U , 0 , false ) ) ; menuItemCheckUpdate . setText ( Constant . messages . getString ( "cfu.help.menu.check" ) ) ; menuItemCheckUpdate . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent e ) { checkForUpdates ( ) ; } } ) ; } return menuItemCheckUpdate ; }
This method initializes menuItemEncoder
20,674
void processAddOnChanges ( Window caller , AddOnDependencyChecker . AddOnChangesResult changes ) { if ( addonsDialog != null ) { addonsDialog . setDownloadingUpdates ( ) ; } if ( getView ( ) != null ) { Set < AddOn > addOns = new HashSet < > ( changes . getUninstalls ( ) ) ; addOns . addAll ( changes . getOldVersions ( ) ) ; Set < Extension > extensions = new HashSet < > ( ) ; extensions . addAll ( changes . getUnloadExtensions ( ) ) ; extensions . addAll ( changes . getSoftUnloadExtensions ( ) ) ; if ( ! warnUnsavedResourcesOrActiveActions ( caller , addOns , extensions , true ) ) { return ; } } uninstallAddOns ( caller , changes . getUninstalls ( ) , false ) ; Set < AddOn > allAddons = new HashSet < > ( changes . getNewVersions ( ) ) ; allAddons . addAll ( changes . getInstalls ( ) ) ; for ( AddOn addOn : allAddons ) { if ( addonsDialog != null ) { addonsDialog . notifyAddOnDownloading ( addOn ) ; } downloadAddOn ( addOn ) ; } }
Processes the given add - on changes .
20,675
public synchronized String installAddOns ( List < String > addons ) { StringBuilder errorMessages = new StringBuilder ( ) ; AddOnCollection aoc = getLatestVersionInfo ( ) ; if ( aoc == null ) { String error = Constant . messages . getString ( "cfu.cmdline.nocfu" ) ; errorMessages . append ( error ) ; CommandLine . error ( error ) ; } else { for ( String aoName : addons ) { AddOn ao = aoc . getAddOn ( aoName ) ; if ( ao == null ) { String error = Constant . messages . getString ( "cfu.cmdline.noaddon" , aoName ) ; errorMessages . append ( error ) ; errorMessages . append ( "\n" ) ; CommandLine . error ( error ) ; continue ; } AddOnDependencyChecker addOnDependencyChecker = new AddOnDependencyChecker ( getLocalVersionInfo ( ) , aoc ) ; AddOnDependencyChecker . AddOnChangesResult result ; AddOn iao = getLocalVersionInfo ( ) . getAddOn ( aoName ) ; if ( iao != null ) { if ( ! ao . isUpdateTo ( iao ) ) { CommandLine . info ( Constant . messages . getString ( "cfu.cmdline.addoninst" , iao . getFile ( ) . getAbsolutePath ( ) ) ) ; continue ; } result = addOnDependencyChecker . calculateUpdateChanges ( ao ) ; } else { result = addOnDependencyChecker . calculateInstallChanges ( ao ) ; } if ( ! result . getUninstalls ( ) . isEmpty ( ) ) { String error = Constant . messages . getString ( "cfu.cmdline.addoninst.uninstalls.required" , result . getUninstalls ( ) ) ; errorMessages . append ( error ) ; errorMessages . append ( "\n" ) ; CommandLine . error ( error ) ; continue ; } Set < AddOn > allAddOns = new HashSet < > ( ) ; allAddOns . addAll ( result . getInstalls ( ) ) ; allAddOns . addAll ( result . getNewVersions ( ) ) ; for ( AddOn addOn : allAddOns ) { CommandLine . info ( Constant . messages . getString ( "cfu.cmdline.addonurl" , addOn . getUrl ( ) ) ) ; } processAddOnChanges ( null , result ) ; } if ( ! waitAndInstallDownloads ( ) ) { errorMessages . append ( Constant . messages . getString ( "cfu.cmdline.addoninst.error" ) ) . append ( "\n" ) ; } } return errorMessages . toString ( ) ; }
Installs the specified add - ons
20,676
public synchronized String uninstallAddOns ( List < String > addons ) { StringBuilder errorMessages = new StringBuilder ( ) ; AddOnCollection aoc = this . getLocalVersionInfo ( ) ; if ( aoc == null ) { String error = Constant . messages . getString ( "cfu.cmdline.nocfu" ) ; errorMessages . append ( error ) ; CommandLine . error ( error ) ; } else { for ( String aoName : addons ) { AddOn ao = aoc . getAddOn ( aoName ) ; if ( ao == null ) { String error = Constant . messages . getString ( "cfu.cmdline.noaddon" , aoName ) ; errorMessages . append ( error ) ; errorMessages . append ( "\n" ) ; CommandLine . error ( error ) ; continue ; } AddOnDependencyChecker addOnDependencyChecker = new AddOnDependencyChecker ( getLocalVersionInfo ( ) , aoc ) ; Set < AddOn > addonSet = new HashSet < AddOn > ( ) ; addonSet . add ( ao ) ; UninstallationResult result = addOnDependencyChecker . calculateUninstallChanges ( addonSet ) ; if ( result . getUninstallations ( ) . size ( ) > 1 ) { result . getUninstallations ( ) . remove ( ao ) ; String error = Constant . messages . getString ( "cfu.cmdline.addonuninst.uninstalls.required" , result . getUninstallations ( ) ) ; errorMessages . append ( error ) ; errorMessages . append ( "\n" ) ; CommandLine . error ( error ) ; continue ; } if ( this . uninstallAddOn ( null , ao , false ) ) { CommandLine . info ( Constant . messages . getString ( "cfu.cmdline.uninstallok" , aoName ) ) ; } else { String error = Constant . messages . getString ( "cfu.cmdline.uninstallfail" , aoName ) ; errorMessages . append ( error ) ; errorMessages . append ( "\n" ) ; CommandLine . error ( error ) ; } } } return errorMessages . toString ( ) ; }
Uninstalls the specified add - ons
20,677
public void removeToolBarComponent ( Component component ) { validateComponentNonNull ( component ) ; getToolbar ( ) . remove ( component ) ; getToolbar ( ) . validate ( ) ; getToolbar ( ) . repaint ( ) ; }
Removes the given component to the tool bar .
20,678
public void setMaximumSearchResultsGUI ( int maximumSearchResultsGUI ) { if ( this . maximumSearchResultsGUI != maximumSearchResultsGUI ) { this . maximumSearchResultsGUI = maximumSearchResultsGUI ; getConfig ( ) . setProperty ( PARAM_MAXIMUM_RESULTS_GUI , maximumSearchResultsGUI ) ; } }
Sets whether the number of maximum results that should be shown in the results panel .
20,679
public void generateAPIFiles ( List < ApiImplementor > implementors ) throws IOException { this . generateWikiIndex ( ) ; for ( ApiImplementor imp : implementors ) { this . generateAPIFiles ( imp ) ; } this . methods = 0 ; this . generateWikiFull ( ) ; System . out . println ( "Generated a total of " + methods + " methods" ) ; }
Generates the wiki files of the given API implementors .
20,680
private void loadSesssionManagementMethodTypes ( ExtensionHook extensionHook ) { this . sessionManagementMethodTypes = new ArrayList < > ( ) ; this . sessionManagementMethodTypes . add ( new CookieBasedSessionManagementMethodType ( ) ) ; this . sessionManagementMethodTypes . add ( new HttpAuthSessionManagementMethodType ( ) ) ; for ( SessionManagementMethodType t : sessionManagementMethodTypes ) { t . hook ( extensionHook ) ; } if ( log . isInfoEnabled ( ) ) { log . info ( "Loaded session management method types: " + sessionManagementMethodTypes ) ; } }
Loads session management method types and hooks them up .
20,681
public SessionManagementMethodType getSessionManagementMethodTypeForIdentifier ( int id ) { for ( SessionManagementMethodType t : getSessionManagementMethodTypes ( ) ) if ( t . getUniqueIdentifier ( ) == id ) return t ; return null ; }
Gets the session management method type for a given identifier .
20,682
protected static boolean uninstallAddOnExtension ( AddOn addOn , Extension extension , AddOnUninstallationProgressCallback callback ) { boolean uninstalledWithoutErrors = true ; if ( extension . isEnabled ( ) ) { String extUiName = extension . getUIName ( ) ; if ( extension . canUnload ( ) ) { logger . debug ( "Unloading ext: " + extension . getName ( ) ) ; try { extension . unload ( ) ; Control . getSingleton ( ) . getExtensionLoader ( ) . removeExtension ( extension ) ; ExtensionFactory . unloadAddOnExtension ( extension ) ; } catch ( Exception e ) { logger . error ( "An error occurred while uninstalling the extension \"" + extension . getName ( ) + "\" bundled in the add-on \"" + addOn . getId ( ) + "\":" , e ) ; uninstalledWithoutErrors = false ; } } else { logger . debug ( "Cant dynamically unload ext: " + extension . getName ( ) ) ; uninstalledWithoutErrors = false ; } callback . extensionRemoved ( extUiName ) ; } else { ExtensionFactory . unloadAddOnExtension ( extension ) ; } addOn . removeLoadedExtension ( extension ) ; return uninstalledWithoutErrors ; }
Uninstalls the given extension .
20,683
public static boolean uninstallAddOnFiles ( AddOn addOn , AddOnUninstallationProgressCallback callback ) { return uninstallAddOnFiles ( addOn , callback , null ) ; }
Uninstalls the files of the given add - on .
20,684
public int start ( ) { NullAppender na = new NullAppender ( ) ; Logger . getRootLogger ( ) . addAppender ( na ) ; Logger . getRootLogger ( ) . setLevel ( Level . OFF ) ; Logger . getLogger ( ConfigurationUtils . class ) . addAppender ( na ) ; Logger . getLogger ( DefaultFileSystem . class ) . addAppender ( na ) ; try { Constant . getInstance ( ) ; } catch ( final Throwable e ) { System . err . println ( e . getMessage ( ) ) ; return 1 ; } Constant . setLowMemoryOption ( getArgs ( ) . isLowMem ( ) ) ; return 0 ; }
Starts the bootstrap process .
20,685
protected static String getStartingMessage ( ) { DateFormat dateFormat = SimpleDateFormat . getDateTimeInstance ( DateFormat . SHORT , DateFormat . MEDIUM ) ; StringBuilder strBuilder = new StringBuilder ( 200 ) ; strBuilder . append ( Constant . PROGRAM_NAME ) . append ( ' ' ) . append ( Constant . PROGRAM_VERSION ) ; strBuilder . append ( " started " ) ; strBuilder . append ( dateFormat . format ( new Date ( ) ) ) ; strBuilder . append ( " with home " ) . append ( Constant . getZapHome ( ) ) ; return strBuilder . toString ( ) ; }
Gets ZAP s starting message .
20,686
protected ContextSelectComboBox getContextSelectComboBox ( ) { if ( contextSelectBox == null ) { contextSelectBox = new ContextSelectComboBox ( ) ; contextSelectBox . addActionListener ( new ActionListener ( ) { public void actionPerformed ( ActionEvent e ) { contextSelected ( ( Context ) contextSelectBox . getSelectedItem ( ) ) ; } } ) ; } return contextSelectBox ; }
Gets the Context select combo box .
20,687
public static String encode ( Serializable o ) { ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; try { ObjectOutputStream oos = new ObjectOutputStream ( bos ) ; try { oos . writeObject ( o ) ; oos . flush ( ) ; } finally { oos . close ( ) ; } return Base64 . encodeBytes ( bos . toByteArray ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
encode a object to a base64 string
20,688
@ SuppressWarnings ( "unchecked" ) public static < T > T decode ( String base64 ) { try { byte [ ] b = Base64 . decode ( base64 ) ; ByteArrayInputStream bais = new ByteArrayInputStream ( b ) ; ObjectInputStream ois = new ObjectInputStream ( bais ) ; return ( T ) ois . readObject ( ) ; } catch ( IOException | ClassNotFoundException e ) { throw new RuntimeException ( e ) ; } }
decode a base64 string to a object
20,689
private JScrollPane getPaneScroll ( ) { if ( paneScroll == null ) { paneScroll = new JScrollPane ( ) ; paneScroll . setName ( "paneScroll" ) ; paneScroll . setViewportView ( getTreeAlert ( ) ) ; } return paneScroll ; }
This method initializes paneScroll
20,690
public javax . swing . JMenu getMenuImport ( ) { if ( menuImport == null ) { menuImport = new javax . swing . JMenu ( ) ; menuImport . setText ( Constant . messages . getString ( "menu.import" ) ) ; menuImport . setMnemonic ( Constant . messages . getChar ( "menu.import.mnemonic" ) ) ; } return menuImport ; }
This method initializes menuImport
20,691
private ZapMenuItem getMenuFileProperties ( ) { if ( menuFileProperties == null ) { menuFileProperties = new ZapMenuItem ( "menu.file.properties" , View . getSingleton ( ) . getMenuShortcutKeyStroke ( KeyEvent . VK_P , KeyEvent . ALT_DOWN_MASK , false ) ) ; menuFileProperties . setText ( Constant . messages . getString ( "menu.file.properties" ) ) ; menuFileProperties . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent e ) { getMenuFileControl ( ) . properties ( ) ; } } ) ; } return menuFileProperties ; }
This method initializes menuFileProperties
20,692
public JMenu getMenuHelp ( ) { if ( menuHelp == null ) { menuHelp = new JMenu ( ) ; menuHelp . setText ( Constant . messages . getString ( "menu.help" ) ) ; menuHelp . setMnemonic ( Constant . messages . getChar ( "menu.help.mnemonic" ) ) ; menuHelp . add ( getMenuHelpAbout ( ) ) ; menuHelp . add ( getMenuHelpSupport ( ) ) ; } return menuHelp ; }
This method initializes menuHelp
20,693
private ZapMenuItem getMenuHelpAbout ( ) { if ( menuHelpAbout == null ) { menuHelpAbout = new ZapMenuItem ( "menu.help.about" ) ; menuHelpAbout . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent e ) { AboutDialog dialog = new AboutDialog ( View . getSingleton ( ) . getMainFrame ( ) , true ) ; dialog . setVisible ( true ) ; } } ) ; } return menuHelpAbout ; }
This method initializes menuHelpAbout
20,694
public JMenu getMenuAnalyse ( ) { if ( menuAnalyse == null ) { menuAnalyse = new JMenu ( ) ; menuAnalyse . setText ( Constant . messages . getString ( "menu.analyse" ) ) ; menuAnalyse . setMnemonic ( Constant . messages . getChar ( "menu.analyse.mnemonic" ) ) ; } return menuAnalyse ; }
This method initializes jMenu1
20,695
public PassiveScanner getScanner ( int pluginId ) { for ( PassiveScanner scanner : passiveScanners ) { if ( scanner instanceof PluginPassiveScanner ) { if ( ( ( PluginPassiveScanner ) scanner ) . getPluginId ( ) == pluginId ) { return scanner ; } } } return null ; }
Returns the PassiveScan rule with the given id
20,696
public static ContentMatcher getInstance ( InputStream xmlInputStream ) { ContentMatcher cm = new ContentMatcher ( ) ; try { cm . loadXMLPatternDefinitions ( xmlInputStream ) ; } catch ( JDOMException | IOException ex ) { throw new IllegalArgumentException ( "Failed to initialize the ContentMatcher object using that stream" , ex ) ; } return cm ; }
Direct method for a complete ContentMatcher instance creation .
20,697
public String findInContent ( String content ) { for ( BoyerMooreMatcher matcher : strings ) { if ( matcher . findInContent ( content ) >= 0 ) return matcher . getPattern ( ) ; } Matcher matcher ; for ( Pattern pattern : patterns ) { matcher = pattern . matcher ( content ) ; if ( matcher . find ( ) ) { return matcher . group ( ) ; } } return null ; }
Search for an occurrence inside a specific content
20,698
public List < String > findAllInContent ( String content ) { List < String > results = new LinkedList < String > ( ) ; for ( BoyerMooreMatcher matcher : strings ) { if ( matcher . findInContent ( content ) >= 0 ) results . add ( matcher . getPattern ( ) ) ; } Matcher matcher ; for ( Pattern pattern : patterns ) { matcher = pattern . matcher ( content ) ; if ( matcher . find ( ) ) { results . add ( content ) ; } } return results ; }
Search for all possible occurrences inside a specific content
20,699
public void sendAndReceive ( HttpMessage msg , boolean isFollowRedirect ) throws IOException { log . debug ( "sendAndReceive " + msg . getRequestHeader ( ) . getMethod ( ) + " " + msg . getRequestHeader ( ) . getURI ( ) + " start" ) ; msg . setTimeSentMillis ( System . currentTimeMillis ( ) ) ; try { notifyRequestListeners ( msg ) ; if ( ! isFollowRedirect || ! ( msg . getRequestHeader ( ) . getMethod ( ) . equalsIgnoreCase ( HttpRequestHeader . POST ) || msg . getRequestHeader ( ) . getMethod ( ) . equalsIgnoreCase ( HttpRequestHeader . PUT ) ) ) { sendAuthenticated ( msg , isFollowRedirect ) ; return ; } sendAuthenticated ( msg , false ) ; HttpMessage temp = msg . cloneAll ( ) ; temp . setRequestingUser ( getUser ( msg ) ) ; for ( int i = 0 ; i < 1 && ( HttpStatusCode . isRedirection ( temp . getResponseHeader ( ) . getStatusCode ( ) ) && temp . getResponseHeader ( ) . getStatusCode ( ) != HttpStatusCode . NOT_MODIFIED ) ; i ++ ) { String location = temp . getResponseHeader ( ) . getHeader ( HttpHeader . LOCATION ) ; URI baseUri = temp . getRequestHeader ( ) . getURI ( ) ; URI newLocation = new URI ( baseUri , location , false ) ; temp . getRequestHeader ( ) . setURI ( newLocation ) ; temp . getRequestHeader ( ) . setMethod ( HttpRequestHeader . GET ) ; temp . getRequestHeader ( ) . setHeader ( HttpHeader . CONTENT_LENGTH , null ) ; sendAuthenticated ( temp , true ) ; } msg . setResponseHeader ( temp . getResponseHeader ( ) ) ; msg . setResponseBody ( temp . getResponseBody ( ) ) ; } finally { msg . setTimeElapsedMillis ( ( int ) ( System . currentTimeMillis ( ) - msg . getTimeSentMillis ( ) ) ) ; log . debug ( "sendAndReceive " + msg . getRequestHeader ( ) . getMethod ( ) + " " + msg . getRequestHeader ( ) . getURI ( ) + " took " + msg . getTimeElapsedMillis ( ) ) ; notifyResponseListeners ( msg ) ; } }
Send and receive a HttpMessage .