私はクライアントのセキュリティレビューに取り組んでおり、config.xmlでこの行に出くわしました.Androidデバイス用のphonegapアプリです
<access origin=".*"/>
origin=* だけだった場合、他のサイトにアクセスできることを意味します。しかし、 .* はどういう意味ですか? *と同じですか?
ありがとう
Cordova Androidソースコードから:
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);
}
}
したがって、正確ではない場合、明らかにすべてを正規表現として扱います*
。文書化されておらず、対象のW3C Widget Access仕様にも含まれていないため、その動作を信頼するのはおそらく良い考えではありません。(おそらく意図したものではないと思います。)
ただし.*
、PhoneGap 2.5.0 プロジェクト テンプレートではまだ使用されているため、PhoneGap の 1 つのバージョンを使用している限り、現時点では問題ありません。
私はそれが必要だとは思わない:
http://www.w3.org/TR/widgets-access/
PhoneGap ドキュメントには記載されていません:
http://docs.phonegap.com/en/2.5.0/guide_whitelist_index.md.html#Domain%20Whitelist%20ガイド
正規表現は次のとおりです。
http://www.regular-expressions.info/reference.html
".*" matches
"def" "ghi" in
abc "def" "ghi" jkl