Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extracted/*
60 changes: 60 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright (c) 2016 Qualcomm Technologies, Inc.
# All Rights Reserved.
# Confidential and Proprietary - Qualcomm Technologies, Inc.

if (is_android) {
import("//build/buildflag_header.gni")
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")

_target_arch = target_cpu
_build_type = "Release"
if (is_debug) {
_build_type = "Debug"
}

copy("copy_libswewebrefiner") {
sources = [ "$_target_arch/$_build_type/libswewebrefiner.so" ]
outputs = [ "$root_shlib_dir/libswewebrefiner.so" ]
data = [ "$root_shlib_dir/libswewebrefiner.so" ]
}

group("libswewebrefiner") {
public_deps = [
":copy_libswewebrefiner",
"//swe/swe_core:swe_core_native",
]
}

_wr_res_zip_path = "//components/web_refiner/java/libswewebrefiner_java.zip"
_wr_unpacked_res_path = "//components/web_refiner/extracted/res/"

_rebased_res_dir = rebase_path(_wr_unpacked_res_path, root_build_dir)
_wr_res_dir_exists = exec_script("//build/dir_exists.py", [ _rebased_res_dir ], "string") == "True"
if (!_wr_res_dir_exists) {
exec_script("//build/makedirs.py", [ _rebased_res_dir ], "string")
}

_wr_extract_res_depfile = "//components/web_refiner/extracted/wr_extract_res.d"
_wr_extract_res_stamp = "//components/web_refiner/extracted/wr_extract_res.stamp"

extract_zip_args = [
"--zip", rebase_path(_wr_res_zip_path, root_build_dir),
"--exdir", rebase_path(_wr_unpacked_res_path, root_build_dir),
"--depfile", rebase_path(_wr_extract_res_depfile, root_build_dir),
"--stamp", rebase_path(_wr_extract_res_stamp, root_build_dir),
]
exec_script("//components/web_refiner/extract_zip.py", extract_zip_args)

android_resources("libswewebrefiner_java_resources") {
custom_package = "com.qualcomm.qti.webrefiner"
resource_dirs = [ _wr_unpacked_res_path ]
}

android_java_prebuilt("libswewebrefiner_java") {
jar_path = "//components/web_refiner/java/libswewebrefiner_java.jar"
deps = [
":libswewebrefiner_java_resources",
]
}
}
3 changes: 3 additions & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
WebRefiner-2.6.5
Built on Chromium-57.0 @ 146c2fd97c8e227646f9b43ba3536a918318804d
Source @ 56f05ebcc4abe75dac4c036979d6711412f6f167
47 changes: 47 additions & 0 deletions WEBDEFENDER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
### WebDefender
WebDefender enhances the anti-tracking technology originally developed by the Electronic Frontier Foundation for the browser extension Privacy Badger. Implemented natively within “Smart Protect - Web”, WebDefender uses machine learning to detect third-party websites who are exhibiting tracking behavior and blocks them.

#### UI Enablement (in SWE Browser):
* Default: toggle the option in Menu > Settings > Site settings > "Web Defender"
* Per-site (Overrides the default option on a per-website basis): toggle the option in Top-left Favicon Button > "Web Defender"

#### Configuration:
- Web Defender is enabled by default.
- Web Defender can use Disconnect.me's services.json list to improve the user experiencing by white-listing CDN domains that serve website contents which would otherwise be blocked by Web Defender and cause breakages in some websites.

- To configure URL to your Disconnect.me services list
```
{
"version": "1.0",
"update": {},
"subscriptions": [
{
"name" : "DisconnectMe Services List",
"category" : "DISCONNECT_ME_SERVICES_LIST",
"format" : "WebDefender 1.0",
"url" : "<url-to-services-list>",
"expiration" : "4 days"
}
]
}
```
- Create a file called **web_defender_conf** with the above configuration
- Add a valid URL in place of **<url-to-services-list>**
- Copy the **web_defender_conf** into **<your-channel>/res/raw/web_defender_conf** and build your browser.

#### WebDefender libraries:
- The libraries listed in this repository are built on top of SWE based on Chromium version specified in the VERSION file. Attempting to use these libraries in any other version of chromium will result in instability.
- `libswewebrefiner.so` is built with dependency on `libswe.so`. If you are changing the chromium library name to something else in your project, then `libswewebrefiner.so` library loading will simply fail at runtime.
- Libraries support ARM (32-bit) architecture only.

#### Browser command line arguments:
```
--disable-web-defender disables WebDefender completely
--enable-web-refiner-logcat-stats enables logcat output of WebDefender and WebRefiner actions
```

#### Debugging: Logcat messages:
```
logcat -s WebDefender generic WebDefender failure messages
logcat -s WebDefenderStat filter stats when '--enable-web-refiner-logcat-stats' is used
```
34 changes: 34 additions & 0 deletions WEBREFINER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
### WebRefiner
WebRefiner is a content filtering component for SWE Browser. It provides a core filtering engine for filtering URLs and a DOM manipulator for applying cosmetic filters on web pages to block advertisements, privacy info trackers and malware domains.

`TL;DR: you should change the subscription.url(s) in web_refiner_conf, and you're good to go.`

#### UI Enablement (in SWE Browser):
* Default: toggle the option in Menu > Settings > Site settings > "Web Refiner"
* Per-site (Overrides the default option on a per-website basis): toggle the option in Top-left Favicon Button > "Web Refiner"

#### Filter configuration:
- The configuration file is in: **chrome/android/java/res/raw/web_refiner_conf**
- By default **web_refiner_conf** contains no valid subscription URLs.
- WebRefiner looks for the configuration only in the above path and failure to provide a valid configuration will result in a failed initialization of WebRefiner (and WebRefiner won't be shown in the UI)
- WebRefiner is fully compatible with the *leading ad-blocking filter list formats*. A wide variety of public filters can be configured in `subscriptions.url` or you can create your own compatible filter list.
- Subscriptions configured in **web_refiner_conf** will always be downloaded from a http/https server at the very first browser startup and they will be updated periodically according their expiration.
- All the downloaded filter files (and internal WebRefiner data) are stored in device `/data/data/<browser-application>/web_refiner/`. Deleting the folder, or clearing the APP DATA will bring WebRefiner back to its default state.
- Filters are applied in the same order as in the configuration file.

#### WebRefiner libraries:
- The libraries listed in this repository are built on top of SWE based on Chromium version specified in the VERSION file. Attempting to use these libraries in any other version of chromium will result in instability.
- `libswewebrefiner.so` is built with dependency on `libswe.so`. If you are changing the chromium library name to something else in your project, then `libswewebrefiner.so` library loading will simply fail at runtime.
- Libraries support ARM (32-bit) architecture only.

#### Browser command line arguments:
```
--disable-web-refiner disables WebRefiner completely
--enable-web-refiner-logcat-stats enables logcat output of applied filters
```

#### Debugging: Logcat messages:
```
logcat -s WebRefiner generic WebRefiner failure messages
logcat -s WebRefinerStat filter stats when '--enable-web-refiner-logcat-stats' is used
```
Binary file added arm/Debug/libswewebrefiner.so
Binary file not shown.
Binary file added arm/Release/libswewebrefiner.so
Binary file not shown.
50 changes: 50 additions & 0 deletions extract_zip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env python
#
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Copyright (c) 2016 Qualcomm Technologies, Inc.
# All Rights Reserved.
# Confidential and Proprietary - Qualcomm Technologies, Inc.
#

import fnmatch
import optparse
import os
import sys

REPOSITORY_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))

sys.path.append(os.path.join(REPOSITORY_ROOT, 'build/android/gyp/util'))
import build_utils

def ExtractZip(options):

zip_path = options.zip
extract_path = options.exdir
build_utils.DeleteDirectory(extract_path)
build_utils.MakeDirectory(extract_path)
unzip_cmd = ['unzip', '-qq', zip_path, '-d', extract_path]
build_utils.CheckOutput(unzip_cmd)

def main():
parser = optparse.OptionParser()
build_utils.AddDepfileOption(parser)
parser.add_option('--zip', help='Zip file path.')
parser.add_option('--exdir', help='Extract files into exdir')
parser.add_option('--stamp', help='Path to touch on success.')

options, _ = parser.parse_args()

ExtractZip(options)

if options.depfile:
build_utils.WriteDepfile(options.depfile, options.zip)

if options.stamp:
build_utils.Touch(options.stamp)


if __name__ == '__main__':
sys.exit(main())
80 changes: 80 additions & 0 deletions generate_secure_connect_rulesets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#! /usr/bin/python

#
# Copyright (c) 2016 Qualcomm Technologies, Inc.
# All Rights Reserved.
# Confidential and Proprietary - Qualcomm Technologies, Inc.
#

import xml.etree.ElementTree as ET
import sys
import os, glob, re
import argparse

parser = argparse.ArgumentParser(
description="This script generates a ruleset file that contains mapping of HTTP URLs \
to corresponding HTTPS URLs. The input is a directory containing XML files with ruleset \
definitions. The output file is generated using Protocol Buffer compiler.")

parser.add_argument('rules_dir', metavar='<XML Directory>', nargs=1,
help='The input directory that contains ruleset definition XML files')

parser.add_argument('output_file', metavar='<Data File>', nargs=1,
help='The output file that the script will generate')
parser.add_argument('-v', '--verbose', type=int, default=[0],
nargs=1, help='Level of verbosity (default 0)')
parser.add_argument('-i', '--include', default=['.'],
nargs=1, help='Location of secure_connect_ruleset_pb2 package (default = current folder)')

args = parser.parse_args()

rules_dir = args.rules_dir[0];
output_file = args.output_file[0];
verbosity = args.verbose[0]
include_dir = args.include[0]

sys.path.append(include_dir)

import secure_connect_ruleset_pb2

files = glob.glob(rules_dir + '/*.xml')
ruleset_list = secure_connect_ruleset_pb2.RuleSetList()

for file in files:
if verbosity > 0:
print "Parsing " + file
tree = ET.parse(file)
root = tree.getroot()

if root.tag == 'ruleset':
if verbosity > 1:
print root.tag, root.attrib
ruleset = ruleset_list.ruleset.add()
ruleset.name = root.attrib['name']
if 'default_off' in root.attrib.keys():
ruleset.default_off = root.attrib['default_off']

for child in root:
if verbosity > 2:
print child.tag, child.attrib
if child.tag == 'target':
target = ruleset.targets.add()
target.host = child.attrib['host']

if child.tag == 'rule':
rule = ruleset.rules.add()
rule.regex = child.attrib['from']
rule.to = child.attrib['to']

if child.tag == 'exclusion':
exclusion = ruleset.exclusions.add()
exclusion.pattern = child.attrib['pattern']

if child.tag == 'securecookie':
securecookie = ruleset.securecookies.add()
securecookie.host = child.attrib['host']
securecookie.name = child.attrib['name']

output = open(output_file, "wb")
output.write(ruleset_list.SerializeToString())
output.close()
Binary file added java/libswewebrefiner_java.jar
Binary file not shown.
Binary file added java/libswewebrefiner_java.zip
Binary file not shown.
Loading