mirror of
https://forge.fsky.io/oneflux/omegafox.git
synced 2026-02-10 22:52:04 -08:00
Add config type validator
- Validates property types passed in --config. - Types are stored in properties.json.
This commit is contained in:
parent
c5356e9e41
commit
a2cb02df8a
7 changed files with 153 additions and 18 deletions
3
Makefile
3
Makefile
|
|
@ -109,6 +109,7 @@ package-linux:
|
||||||
python3 scripts/package.py linux \
|
python3 scripts/package.py linux \
|
||||||
--includes \
|
--includes \
|
||||||
settings/chrome.css \
|
settings/chrome.css \
|
||||||
|
settings/properties.json \
|
||||||
bundle/fontconfigs \
|
bundle/fontconfigs \
|
||||||
--version $(version) \
|
--version $(version) \
|
||||||
--release $(release) \
|
--release $(release) \
|
||||||
|
|
@ -120,6 +121,7 @@ package-macos:
|
||||||
python3 scripts/package.py macos \
|
python3 scripts/package.py macos \
|
||||||
--includes \
|
--includes \
|
||||||
settings/chrome.css \
|
settings/chrome.css \
|
||||||
|
settings/properties.json \
|
||||||
--version $(version) \
|
--version $(version) \
|
||||||
--release $(release) \
|
--release $(release) \
|
||||||
--arch $(arch) \
|
--arch $(arch) \
|
||||||
|
|
@ -130,6 +132,7 @@ package-windows:
|
||||||
python3 scripts/package.py windows \
|
python3 scripts/package.py windows \
|
||||||
--includes \
|
--includes \
|
||||||
settings/chrome.css \
|
settings/chrome.css \
|
||||||
|
settings/properties.json \
|
||||||
~/.mozbuild/vs/VC/Redist/MSVC/14.38.33135/$(vcredist_arch)/Microsoft.VC143.CRT/*.dll \
|
~/.mozbuild/vs/VC/Redist/MSVC/14.38.33135/$(vcredist_arch)/Microsoft.VC143.CRT/*.dll \
|
||||||
--version $(version) \
|
--version $(version) \
|
||||||
--release $(release) \
|
--release $(release) \
|
||||||
|
|
|
||||||
22
README.md
22
README.md
|
|
@ -151,13 +151,17 @@ Screen
|
||||||
| screen.availWidth | ✅ |
|
| screen.availWidth | ✅ |
|
||||||
| screen.availTop | ✅ |
|
| screen.availTop | ✅ |
|
||||||
| screen.availLeft | ✅ |
|
| screen.availLeft | ✅ |
|
||||||
| screen.colorDepth | ✅ |
|
|
||||||
| screen.height | ✅ |
|
| screen.height | ✅ |
|
||||||
| screen.width | ✅ |
|
| screen.width | ✅ |
|
||||||
|
| screen.colorDepth | ✅ |
|
||||||
| screen.pixelDepth | ✅ |
|
| screen.pixelDepth | ✅ |
|
||||||
| screen.pageXOffset | ✅ |
|
| screen.pageXOffset | ✅ |
|
||||||
| screen.pageYOffset | ✅ |
|
| screen.pageYOffset | ✅ |
|
||||||
|
|
||||||
|
**Notes:**
|
||||||
|
|
||||||
|
- `screen.colorDepth` and `screen.pixelDepth` are synonymous.
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
|
@ -165,20 +169,20 @@ Screen
|
||||||
Window
|
Window
|
||||||
</summary>
|
</summary>
|
||||||
|
|
||||||
| Property | Status |
|
| Property | Status | Notes |
|
||||||
| ----------------------- | --------------------------- |
|
| ----------------------- | ------ | ------------------------------- |
|
||||||
| window.scrollMinX | ✅ |
|
| window.scrollMinX | ✅ |
|
||||||
| window.scrollMinY | ✅ |
|
| window.scrollMinY | ✅ |
|
||||||
| window.scrollMaxX | ✅ |
|
| window.scrollMaxX | ✅ |
|
||||||
| window.scrollMaxY | ✅ |
|
| window.scrollMaxY | ✅ |
|
||||||
| window.innerHeight | ✅ |
|
| window.outerHeight | ✅ | Sets the window height. |
|
||||||
| window.outerHeight | ✅ |
|
| window.outerWidth | ✅ | Sets the window width. |
|
||||||
| window.outerWidth | ✅ |
|
| window.innerHeight | ✅ | Sets the inner viewport height. |
|
||||||
| window.innerWidth | ✅ |
|
| window.innerWidth | ✅ | Sets the inner viewport width. |
|
||||||
| window.screenX | ✅ |
|
| window.screenX | ✅ |
|
||||||
| window.screenY | ✅ |
|
| window.screenY | ✅ |
|
||||||
| window.history.length | ✅ |
|
| window.history.length | ✅ |
|
||||||
| window.devicePixelRatio | Works, but not recommended! |
|
| window.devicePixelRatio | ✅ | Works, but not recommended. |
|
||||||
|
|
||||||
**Notes:**
|
**Notes:**
|
||||||
|
|
||||||
|
|
@ -269,7 +273,7 @@ You can also exclude default addons with the `--exclude-addons` flag:
|
||||||
Miscellaneous (WebGl spoofing, battery status, etc)
|
Miscellaneous (WebGl spoofing, battery status, etc)
|
||||||
</summary>
|
</summary>
|
||||||
|
|
||||||
| Property | Status | Notes |
|
| Property | Status | Description |
|
||||||
| ----------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ----------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| pdfViewer | ✅ | Sets navigator.pdfViewerEnabled. Please keep this on though, many websites will flag a lack of pdfViewer as a headless browser. |
|
| pdfViewer | ✅ | Sets navigator.pdfViewerEnabled. Please keep this on though, many websites will flag a lack of pdfViewer as a headless browser. |
|
||||||
| webGl:renderer | ✅ | Spoofs the name of the unmasked WebGL renderer. Can cause leaks, use at your own caution! Also note, webGl is disabled in Camoufox by default. |
|
| webGl:renderer | ✅ | Spoofs the name of the unmasked WebGL renderer. Can cause leaks, use at your own caution! Also note, webGl is disabled in Camoufox by default. |
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ func main() {
|
||||||
// Read and parse the config file
|
// Read and parse the config file
|
||||||
var configMap map[string]interface{}
|
var configMap map[string]interface{}
|
||||||
parseJson(configPath, &configMap)
|
parseJson(configPath, &configMap)
|
||||||
|
validateConfig(configMap)
|
||||||
|
|
||||||
//*** PARSE ADDONS ***//
|
//*** PARSE ADDONS ***//
|
||||||
|
|
||||||
|
|
@ -199,7 +200,7 @@ func setEnvironmentVariables(configMap map[string]interface{}, userAgentOS strin
|
||||||
}
|
}
|
||||||
|
|
||||||
if normalizeOS(runtime.GOOS) == "linux" {
|
if normalizeOS(runtime.GOOS) == "linux" {
|
||||||
fontconfigPath := filepath.Join("fontconfig", userAgentOS)
|
fontconfigPath := getPath(filepath.Join("fontconfig", userAgentOS))
|
||||||
os.Setenv("FONTCONFIG_PATH", fontconfigPath)
|
os.Setenv("FONTCONFIG_PATH", fontconfigPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
67
launcher/validate.go
Normal file
67
launcher/validate.go
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
|
"os"
|
||||||
|
"reflect"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Property struct {
|
||||||
|
Property string `json:"property"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func validateConfig(configMap map[string]interface{}) {
|
||||||
|
properties := loadProperties()
|
||||||
|
|
||||||
|
// Create a map for quick lookup of property types
|
||||||
|
propertyTypes := make(map[string]string)
|
||||||
|
for _, prop := range properties {
|
||||||
|
propertyTypes[prop.Property] = prop.Type
|
||||||
|
}
|
||||||
|
|
||||||
|
for key, value := range configMap {
|
||||||
|
expectedType, exists := propertyTypes[key]
|
||||||
|
if !exists {
|
||||||
|
fmt.Printf("Warning: Unknown property %s in config\n", key)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if !validateType(value, expectedType) {
|
||||||
|
fmt.Printf("Invalid type for property %s. Expected %s, got %T\n", key, expectedType, value)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadProperties() []Property {
|
||||||
|
propertiesPath := getPath("properties.json")
|
||||||
|
var properties []Property
|
||||||
|
parseJson(propertiesPath, &properties)
|
||||||
|
return properties
|
||||||
|
}
|
||||||
|
|
||||||
|
func validateType(value interface{}, expectedType string) bool {
|
||||||
|
switch expectedType {
|
||||||
|
case "str":
|
||||||
|
_, ok := value.(string)
|
||||||
|
return ok
|
||||||
|
case "int":
|
||||||
|
v, ok := value.(float64)
|
||||||
|
return ok && v == math.Trunc(v)
|
||||||
|
case "uint":
|
||||||
|
v, ok := value.(float64)
|
||||||
|
return ok && v == math.Trunc(v) && v >= 0
|
||||||
|
case "double":
|
||||||
|
_, ok := value.(float64)
|
||||||
|
return ok
|
||||||
|
case "bool":
|
||||||
|
_, ok := value.(bool)
|
||||||
|
return ok
|
||||||
|
case "array":
|
||||||
|
return reflect.TypeOf(value).Kind() == reflect.Slice
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -18,10 +18,11 @@ diff --git a/lw/moz.build b/lw/moz.build
|
||||||
index e69de29bb2..208184547e 100644
|
index e69de29bb2..208184547e 100644
|
||||||
--- a/lw/moz.build
|
--- a/lw/moz.build
|
||||||
+++ b/lw/moz.build
|
+++ b/lw/moz.build
|
||||||
@@ -0,0 +1,13 @@
|
@@ -0,0 +1,14 @@
|
||||||
+FINAL_TARGET_FILES += [
|
+FINAL_TARGET_FILES += [
|
||||||
+ "camoufox.cfg",
|
+ "camoufox.cfg",
|
||||||
+ "chrome.css",
|
+ "chrome.css",
|
||||||
|
+ "properties.json"
|
||||||
+]
|
+]
|
||||||
+
|
+
|
||||||
+FINAL_TARGET_FILES.distribution += [
|
+FINAL_TARGET_FILES.distribution += [
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ run 'cp -v ../../settings/camoufox.cfg .'
|
||||||
run 'cp -v ../../settings/distribution/policies.json .'
|
run 'cp -v ../../settings/distribution/policies.json .'
|
||||||
run 'cp -v ../../settings/defaults/pref/local-settings.js .'
|
run 'cp -v ../../settings/defaults/pref/local-settings.js .'
|
||||||
run 'cp -v ../../settings/chrome.css .'
|
run 'cp -v ../../settings/chrome.css .'
|
||||||
|
run 'cp -v ../../settings/properties.json .'
|
||||||
run 'touch moz.build'
|
run 'touch moz.build'
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
|
||||||
|
|
|
||||||
58
settings/properties.json
Normal file
58
settings/properties.json
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
[
|
||||||
|
{ "property": "navigator.userAgent", "type": "str" },
|
||||||
|
{ "property": "navigator.doNotTrack", "type": "str" },
|
||||||
|
{ "property": "navigator.appCodeName", "type": "str" },
|
||||||
|
{ "property": "navigator.appName", "type": "str" },
|
||||||
|
{ "property": "navigator.appVersion", "type": "str" },
|
||||||
|
{ "property": "navigator.oscpu", "type": "str" },
|
||||||
|
{ "property": "navigator.language", "type": "str" },
|
||||||
|
{ "property": "navigator.languages", "type": "array" },
|
||||||
|
{ "property": "navigator.platform", "type": "str" },
|
||||||
|
{ "property": "navigator.hardwareConcurrency", "type": "uint" },
|
||||||
|
{ "property": "navigator.product", "type": "str" },
|
||||||
|
{ "property": "navigator.productSub", "type": "str" },
|
||||||
|
{ "property": "navigator.maxTouchPoints", "type": "uint" },
|
||||||
|
{ "property": "navigator.cookieEnabled", "type": "bool" },
|
||||||
|
{ "property": "navigator.globalPrivacyControl", "type": "bool" },
|
||||||
|
{ "property": "navigator.buildID", "type": "str" },
|
||||||
|
{ "property": "navigator.onLine", "type": "bool" },
|
||||||
|
{ "property": "screen.availHeight", "type": "uint" },
|
||||||
|
{ "property": "screen.availWidth", "type": "uint" },
|
||||||
|
{ "property": "screen.availTop", "type": "uint" },
|
||||||
|
{ "property": "screen.availLeft", "type": "uint" },
|
||||||
|
{ "property": "screen.height", "type": "uint" },
|
||||||
|
{ "property": "screen.width", "type": "uint" },
|
||||||
|
{ "property": "screen.colorDepth", "type": "uint" },
|
||||||
|
{ "property": "screen.pixelDepth", "type": "uint" },
|
||||||
|
{ "property": "screen.pageXOffset", "type": "double" },
|
||||||
|
{ "property": "screen.pageYOffset", "type": "double" },
|
||||||
|
{ "property": "window.scrollMinX", "type": "int" },
|
||||||
|
{ "property": "window.scrollMinY", "type": "int" },
|
||||||
|
{ "property": "window.scrollMaxX", "type": "int" },
|
||||||
|
{ "property": "window.scrollMaxY", "type": "int" },
|
||||||
|
{ "property": "window.outerHeight", "type": "uint" },
|
||||||
|
{ "property": "window.outerWidth", "type": "uint" },
|
||||||
|
{ "property": "window.innerHeight", "type": "uint" },
|
||||||
|
{ "property": "window.innerWidth", "type": "uint" },
|
||||||
|
{ "property": "window.screenX", "type": "int" },
|
||||||
|
{ "property": "window.screenY", "type": "int" },
|
||||||
|
{ "property": "window.history.length", "type": "uint" },
|
||||||
|
{ "property": "window.devicePixelRatio", "type": "double" },
|
||||||
|
{ "property": "document.body.clientWidth", "type": "uint" },
|
||||||
|
{ "property": "document.body.clientHeight", "type": "uint" },
|
||||||
|
{ "property": "document.body.clientTop", "type": "uint" },
|
||||||
|
{ "property": "document.body.clientLeft", "type": "uint" },
|
||||||
|
{ "property": "headers.User-Agent", "type": "str" },
|
||||||
|
{ "property": "headers.Accept-Language", "type": "str" },
|
||||||
|
{ "property": "headers.Accept-Encoding", "type": "str" },
|
||||||
|
{ "property": "webrtc:ipv4", "type": "str" },
|
||||||
|
{ "property": "webrtc:ipv6", "type": "str" },
|
||||||
|
{ "property": "pdfViewerEnabled", "type": "bool" },
|
||||||
|
{ "property": "webGl:renderer", "type": "str" },
|
||||||
|
{ "property": "webGl:vendor", "type": "str" },
|
||||||
|
{ "property": "battery:charging", "type": "bool" },
|
||||||
|
{ "property": "battery:chargingTime", "type": "double" },
|
||||||
|
{ "property": "battery:dischargingTime", "type": "double" },
|
||||||
|
{ "property": "battery:level", "type": "double" },
|
||||||
|
{ "property": "fonts", "type": "array" }
|
||||||
|
]
|
||||||
Loading…
Add table
Reference in a new issue