Index: webkit/plugins/npapi/plugin_group.h |
=================================================================== |
--- webkit/plugins/npapi/plugin_group.h (revision 138513) |
+++ webkit/plugins/npapi/plugin_group.h (working copy) |
@@ -25,6 +25,17 @@ |
class PluginList; |
class MockPluginList; |
+// Hard-coded version ranges for plugin groups. |
+struct VersionRangeDefinition { |
+ // Matcher for lowest version matched by this range (inclusive). May be empty |
+ // to match everything iff |version_matcher_high| is also empty. |
+ const char* version_matcher_low; |
+ // Matcher for highest version matched by this range (exclusive). May be empty |
+ // to match anything higher than |version_matcher_low|. |
+ const char* version_matcher_high; |
+ const char* min_version; // Minimum secure version. |
+}; |
+ |
// Hard-coded definitions of plugin groups. |
struct PluginGroupDefinition { |
// Unique identifier for this group. |
@@ -33,11 +44,36 @@ |
const char* name; |
// Substring matcher for the plugin name. |
const char* name_matcher; |
+ // List of version ranges. |
+ const VersionRangeDefinition* versions; |
+ // Size of the array |versions| points to. |
+ size_t num_versions; |
}; |
+// Run-time structure to hold version range information. |
+struct VersionRange { |
+ public: |
+ explicit VersionRange(const VersionRangeDefinition& definition); |
+ VersionRange(const VersionRange& other); |
+ VersionRange& operator=(const VersionRange& other); |
+ ~VersionRange(); |
+ |
+ std::string low_str; |
+ std::string high_str; |
+ std::string min_str; |
+ scoped_ptr<Version> low; |
+ scoped_ptr<Version> high; |
+ scoped_ptr<Version> min; |
+ private: |
+ void InitFrom(const VersionRange& other); |
+}; |
+ |
// A PluginGroup can match a range of versions of a specific plugin (as defined |
// by matching a substring of its name). |
// It contains all WebPluginInfo structs (at least one) matching its definition. |
+// In addition, it knows about a security "baseline", i.e. the minimum version |
+// of a plugin that is needed in order not to exhibit known security |
+// vulnerabilities. |
class WEBKIT_PLUGINS_EXPORT PluginGroup { |
public: |
@@ -82,6 +118,9 @@ |
// Checks whether a plugin exists in the group with the given path. |
bool ContainsPlugin(const FilePath& path) const; |
+ // Returns true if |plugin| in this group has known security problems. |
+ bool IsVulnerable(const WebPluginInfo& plugin) const; |
+ |
// Check if the group has no plugins. Could happen after a reload if the plug- |
// in has disappeared from the pc (or in the process of updating). |
bool IsEmpty() const; |
@@ -94,6 +133,10 @@ |
return web_plugin_infos_; |
} |
+ const std::vector<VersionRange>& version_ranges() const { |
+ return version_ranges_; |
+ } |
+ |
private: |
friend class MockPluginList; |
friend class PluginGroupTest; |
@@ -117,6 +160,15 @@ |
// the created PluginGroup. |
static PluginGroup* FromWebPluginInfo(const webkit::WebPluginInfo& wpi); |
+ // Returns |true| if |version| is contained in [low, high) of |range|. |
+ static bool IsVersionInRange(const Version& version, |
+ const VersionRange& range); |
+ |
+ // Returns |true| iff |plugin_version| is both contained in |version_range| |
+ // and declared outdated (== vulnerable) by it. |
+ static bool IsPluginOutdated(const Version& plugin_version, |
+ const VersionRange& version_range); |
+ |
PluginGroup(const string16& group_name, |
const string16& name_matcher, |
const std::string& identifier); |
@@ -132,6 +184,7 @@ |
std::string identifier_; |
string16 group_name_; |
string16 name_matcher_; |
+ std::vector<VersionRange> version_ranges_; |
std::vector<webkit::WebPluginInfo> web_plugin_infos_; |
}; |