/
PassiveScanThread.java
144 lines (125 loc) · 4.29 KB
/
PassiveScanThread.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
* Zed Attack Proxy (ZAP) and its related class files.
*
* ZAP is an HTTP/HTTPS proxy for assessing web application security.
*
* Copyright 2011 The ZAP Development Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.zaproxy.zap.extension.pscan;
import java.util.Set;
import org.parosproxy.paros.core.scanner.Alert;
import org.parosproxy.paros.extension.history.ProxyListenerLog;
import org.parosproxy.paros.model.HistoryReference;
/**
* @deprecated (2.12.0) Use {@link org.zaproxy.zap.extension.pscan.PassiveScanController} instead.
*/
@Deprecated
public class PassiveScanThread extends Thread {
public static final int PROXY_LISTENER_ORDER = ProxyListenerLog.PROXY_LISTENER_ORDER + 1;
private PassiveScanTaskHelper helper;
private HistoryReference href = null;
private String currentRuleName = "";
private String currentUrl = "";
private long currentRuleStartTime = 0;
/**
* Constructs a {@code PassiveScanThread} with the given data.
*
* @param helper the helper class
* @param href the history reference being acted upon
* @since 2.12.0
*/
public PassiveScanThread(PassiveScanTaskHelper helper, HistoryReference href) {
if (helper == null) {
throw new IllegalArgumentException("Parameter helper must not be null.");
}
this.helper = helper;
this.href = href;
}
@Override
public void run() {
// Do nothing
}
public void raiseAlert(int id, Alert alert) {
helper.raiseAlert(href, alert);
}
/**
* Adds the given tag to the message being passive scanned.
*
* @param id not used.
* @param tag the name of the tag.
* @deprecated (2.11.0) Use {@link #addTag(String)} instead, the id is not used.
*/
@Deprecated
public void addTag(int id, String tag) {
addTag(tag);
}
/**
* Adds the given tag to the message being passive scanned.
*
* @param tag the name of the tag.
* @since 2.11.0
*/
public void addTag(String tag) {
helper.addHistoryTag(href, tag);
}
/**
* Add the History Type ({@code int}) to the set of applicable history types.
*
* @param type the type to be added to the set of applicable history types
* @since 2.8.0
*/
public static void addApplicableHistoryType(int type) {
PassiveScanTaskHelper.addApplicableHistoryType(type);
}
/**
* Remove the History Type ({@code int}) from the set of applicable history types.
*
* @param type the type to be removed from the set of applicable history types
* @since 2.8.0
*/
public static void removeApplicableHistoryType(int type) {
PassiveScanTaskHelper.removeApplicableHistoryType(type);
}
/**
* Returns the set of History Types which have "opted-in" to be applicable for passive scanning.
*
* @return a set of {@code Integer} representing all of the History Types which have "opted-in"
* for passive scanning.
* @since 2.8.0
*/
public static Set<Integer> getOptedInHistoryTypes() {
return PassiveScanTaskHelper.getOptedInHistoryTypes();
}
/**
* Returns the full set (both default and "opted-in") which are to be applicable for passive
* scanning.
*
* @return a set of {@code Integer} representing all of the History Types which are applicable
* for passive scanning.
* @since 2.8.0
*/
public static Set<Integer> getApplicableHistoryTypes() {
return PassiveScanTaskHelper.getApplicableHistoryTypes();
}
public String getCurrentRuleName() {
return currentRuleName;
}
public String getCurrentUrl() {
return currentUrl;
}
public long getCurrentRuleStartTime() {
return currentRuleStartTime;
}
}