我一直在为客户进行安全审核,并在config.xml中遇到过这一行 它是Android设备的phonegap应用程序
<access origin=".*"/>
如果它只是origin = *我知道这意味着它可以访问任何其他网站。 但。*是什么意思?它与*?
相同感谢
答案 0 :(得分:1)
来自Cordova Android source code:
private void _addWhiteListEntry(String origin, boolean subdomains) {
try {
// Unlimited access to network resources
if (origin.compareTo("*") == 0) {
LOG.d(TAG, "Unlimited access to network resources");
this.whiteList.add(Pattern.compile(".*"));
} else { // specific access
// check if subdomains should be included
// TODO: we should not add more domains if * has already been added
if (subdomains) {
// XXX making it stupid friendly for people who forget to include protocol/SSL
if (origin.startsWith("http")) {
this.whiteList.add(Pattern.compile(origin.replaceFirst("https?://", "^https?://(.*\\.)?")));
} else {
this.whiteList.add(Pattern.compile("^https?://(.*\\.)?" + origin));
}
LOG.d(TAG, "Origin to allow with subdomains: %s", origin);
} else {
// XXX making it stupid friendly for people who forget to include protocol/SSL
if (origin.startsWith("http")) {
this.whiteList.add(Pattern.compile(origin.replaceFirst("https?://", "^https?://")));
} else {
this.whiteList.add(Pattern.compile("^https?://" + origin));
}
LOG.d(TAG, "Origin to allow: %s", origin);
}
}
} catch (Exception e) {
LOG.d(TAG, "Failed to add origin %s", origin);
}
}
显然,如果它不完全是*
,那么它们就像正则表达式一样。信任该行为可能不是一个好主意,因为它不是documented而不是目标W3C Widget Access规范。 (我认为它可能甚至没有打算。)
然而.*
仍然在PhoneGap 2.5.0项目模板中使用,所以只要您使用一个版本的PhoneGap就可以了。
答案 1 :(得分:0)
我认为没有必要:
http://www.w3.org/TR/widgets-access/
PhoneGap文档中未提及:
http://docs.phonegap.com/en/2.5.0/guide_whitelist_index.md.html#Domain%20Whitelist%20Guide
这是正则表达式:
http://www.regular-expressions.info/reference.html
".*" matches
"def" "ghi" in
abc "def" "ghi" jkl
答案 2 :(得分:0)
*表示通配符。当*存在时,表示该应用程序可以访问任何外部站点。它用域替换*,然后它只允许应用程序访问该特定站点。
<access origin="*" /> // all external domains
<access origin="http://google.com" /> // app can only reach google all other doamins are restricted