Skip to content

Commit a575e06

Browse files
committed
Add whitelist functinality documentation
1 parent 3297c32 commit a575e06

File tree

5 files changed

+109
-17
lines changed

5 files changed

+109
-17
lines changed

Diff for: Doxyfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ HTML_HEADER =
186186
HTML_FOOTER =
187187
HTML_STYLESHEET =
188188
HTML_EXTRA_STYLESHEET =
189-
HTML_EXTRA_FILES =
189+
HTML_EXTRA_FILES = ./src/webdriver/whitelist.xsd
190190
HTML_COLORSTYLE_HUE = 220
191191
HTML_COLORSTYLE_SAT = 100
192192
HTML_COLORSTYLE_GAMMA = 80

Diff for: inc/webdriver_access.h

+62-13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
1+
/// \page page_whitelist IP/command whitelist
2+
///Whitelist functionality allows to specify xml-file with list of IP with allowed/denied commands. To pass whitelist file to WebDriver need to use "white-list" server option(\ref page_webdriver_switches)
3+
///\code
4+
/// -white-list=/path/to/whitelist.xml
5+
///\endcode
6+
///If no whitelist xml-file defined then all commands for all IP is allowed.
7+
///
8+
///Example of whitelist.xml:
9+
///\code
10+
/// <?xml version="1.0" encoding="UTF-8"?>
11+
/// <hosts>
12+
/// <host ip="10.32.191.8"/>
13+
/// <host ip="192.27.27.7">
14+
/// <deny url="/session/*/window/*" method="*"/>
15+
/// <deny url="/session/*/click" method="POST"/>
16+
/// </host>
17+
/// <host ip="192.34.191.7">
18+
/// <allow url="/status" method="GET" />
19+
/// </host>
20+
/// </hosts>
21+
///\endcode
22+
///*In this example:
23+
///* - if nothing is specified (10.32.191.8) all command is allowed for that IP;
24+
///* - if "allow" node is specified only these commands is allowed, other disallowed;
25+
///* - if "deny" node is specified this command will be disallowed, all other allowed;
26+
///* - if there will be "allow" and "deny" nodes for one IP, only "deny" will have effect, all other will be allowed;
27+
///* - for all other IP all commands will be disallowed;
28+
///
29+
///To allow some command for any IP wildcard should be used:
30+
///\code
31+
/// <host ip="*">
32+
/// <allow url="/status" method="GET" />
33+
/// </host>
34+
///\endcode
35+
///
36+
///
37+
///There is <a href="whitelist.xsd" target="_blank"><b>xsd</b></a> file to validate/generate whitelist.xml
38+
39+
140
#ifndef WEBDRIVER_ACCESS_H
241
#define WEBDRIVER_ACCESS_H
342

@@ -8,28 +47,38 @@
847

948
namespace webdriver {
1049

11-
struct AccessCommandTable
12-
{
13-
std::string method;
14-
std::string url;
15-
};
16-
17-
struct AccessRule {
18-
long hostIp;
19-
bool isGeneralRule; //for all ip
20-
bool allowed;
21-
std::vector<AccessCommandTable> commandList;
22-
};
23-
50+
/// Provides \ref page_whitelist functionality
2451
class AccessValidator
2552
{
2653
public:
2754
AccessValidator();
2855
~AccessValidator();
56+
57+
///Parse xml file with whitelist config
58+
///@param xmlPath path to whitelist xml-file
2959
void setWhiteList(FilePath &xmlPath);
60+
61+
///Check if given command is allowed for this IP
62+
///@param remote_ip origin IP to check
63+
///@param url command url
64+
///@param method command method
3065
bool isAllowed(const long &remote_ip, const std::string &url, const std::string &method);
3166

3267
private:
68+
69+
struct AccessCommandTable
70+
{
71+
std::string method;
72+
std::string url;
73+
};
74+
75+
struct AccessRule {
76+
long hostIp;
77+
bool isGeneralRule; //for all ip
78+
bool allowed;
79+
std::vector<AccessCommandTable> commandList;
80+
};
81+
3382
bool convertIpString(const char *str_ip, long *int_ip);
3483
std::list<AccessRule> accessList;
3584
};

Diff for: inc/webdriver_server.h

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ extension that allow testing native UI.
1111
- \subpage page_views
1212
- \subpage page_url_post
1313
- \subpage page_hybrid_capabilities
14+
- \subpage page_whitelist
1415
*/
1516

1617
//-----------------------------------------------------------

Diff for: inc/webdriver_switches.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,12 @@ class Switches {
8080
static const char kUserInputDevice[];
8181

8282
/// \page page_webdriver_switches WD Server switches
83-
/// - <b>config</b><br>
83+
/// - <b>white-list</b><br>
8484
/// The path to whitelist file (e.g. whitelist.xml) in
85-
/// XML format with specified list of IP with allowed/disallowed
86-
/// commands for each of them
85+
/// XML format with specified list of IP with allowed/denied
86+
/// commands for each of them. For more information please refer:
87+
///\ref page_whitelist
88+
8789
static const char kWhiteList[];
8890

8991
};

Diff for: src/webdriver/whitelist.xsd

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- edited with XMLSpy v2010 rel. 3 (http://www.altova.com) by Salima Khelifi (NDS Technologies France) -->
3+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
4+
<xs:element name="hosts">
5+
<xs:annotation>
6+
<xs:documentation>whitelist</xs:documentation>
7+
</xs:annotation>
8+
<xs:complexType>
9+
<xs:sequence>
10+
<xs:element name="host" maxOccurs="unbounded">
11+
<xs:complexType>
12+
<xs:sequence minOccurs="0">
13+
<xs:choice maxOccurs="unbounded">
14+
<xs:element name="allow" type="permission"/>
15+
<xs:element name="deny" type="permission"/>
16+
</xs:choice>
17+
</xs:sequence>
18+
<xs:attribute name="ip" type="xs:token"/>
19+
</xs:complexType>
20+
</xs:element>
21+
</xs:sequence>
22+
</xs:complexType>
23+
</xs:element>
24+
<xs:complexType name="permission">
25+
<xs:annotation>
26+
<xs:documentation>allow or deny</xs:documentation>
27+
</xs:annotation>
28+
<xs:attribute name="url" type="xs:token" use="required"/>
29+
<xs:attribute name="method" use="required">
30+
<xs:simpleType>
31+
<xs:restriction base="xs:token">
32+
<xs:enumeration value="POST"/>
33+
<xs:enumeration value="GET"/>
34+
<xs:enumeration value="DELETE"/>
35+
<xs:enumeration value="*"/>
36+
</xs:restriction>
37+
</xs:simpleType>
38+
</xs:attribute>
39+
</xs:complexType>
40+
</xs:schema>

0 commit comments

Comments
 (0)