1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/*
* Copyright (c) 2012 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.
*/
// Manifest processing for JSON manifests.
#ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_JSON_MANIFEST_H_
#define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_JSON_MANIFEST_H_
#include <map>
#include <set>
#include <string>
#include "native_client/src/include/nacl_macros.h"
#include "native_client/src/include/nacl_string.h"
#include "native_client/src/trusted/plugin/manifest.h"
#include "third_party/jsoncpp/source/include/json/value.h"
namespace pp {
class URLUtil_Dev;
} // namespace pp
namespace plugin {
class ErrorInfo;
class PnaclOptions;
class JsonManifest : public Manifest {
public:
JsonManifest(const pp::URLUtil_Dev* url_util,
const nacl::string& manifest_base_url,
const nacl::string& sandbox_isa,
bool prefer_portable)
: url_util_(url_util),
manifest_base_url_(manifest_base_url),
sandbox_isa_(sandbox_isa),
prefer_portable_(prefer_portable),
dictionary_(Json::nullValue) { }
virtual ~JsonManifest() { }
// Initialize the manifest object for use by later lookups. The return
// value is true if the manifest parses correctly and matches the schema.
bool Init(const nacl::string& json, ErrorInfo* error_info);
// Gets the full program URL for the current sandbox ISA from the
// manifest file.
virtual bool GetProgramURL(nacl::string* full_url,
PnaclOptions* pnacl_options,
ErrorInfo* error_info) const;
// Resolves a URL relative to the manifest base URL
virtual bool ResolveURL(const nacl::string& relative_url,
nacl::string* full_url,
ErrorInfo* error_info) const;
// Gets the file names from the "files" section of the manifest. No
// checking that the keys' values are proper ISA dictionaries -- it
// is assumed that other consistency checks take care of that, and
// that the keys are appropriate for use with ResolveKey.
virtual bool GetFileKeys(std::set<nacl::string>* keys) const;
// Resolves a key from the "files" section to a fully resolved URL,
// i.e., relative URL values are fully expanded relative to the
// manifest's URL (via ResolveURL).
// If there was an error, details are reported via error_info.
virtual bool ResolveKey(const nacl::string& key,
nacl::string* full_url,
PnaclOptions* pnacl_options,
ErrorInfo* error_info) const;
private:
NACL_DISALLOW_COPY_AND_ASSIGN(JsonManifest);
// Checks that |dictionary_| is a valid manifest, according to the schema.
// Returns true on success, and sets |error_info| to a detailed message
// if not.
bool MatchesSchema(ErrorInfo* error_info);
const pp::URLUtil_Dev* url_util_;
nacl::string manifest_base_url_;
nacl::string sandbox_isa_;
// Determines whether portable programs are chosen in manifest files over
// native programs.
bool prefer_portable_;
Json::Value dictionary_;
};
} // namespace plugin
#endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_JSON_MANIFEST_H_
|