|
|
Chromium Code Reviews|
Created:
3 years, 9 months ago by ljusten (tachyonic) Modified:
3 years, 9 months ago CC:
chromium-reviews Target Ref:
refs/heads/master Project:
chromium Visibility:
Public. |
DescriptionGenerate code for encoding cloud policy protobufs
Modifies the script that generates code from policy_templates.json to
output policy code that make it easy to iterate over all user policies
to encode data in a cloud policy protobuf.
The code is not used in Chromium. It will be used in Chrome OS's
authpolicy project. Right now, authpolicy uses similar, checked in
code, see policy_keys and in user_policy_encoder_gen.cc
platform2/authpolicy/policy.
This CL is implemented in Chromium, as opposed to a script in Chrome
OS, to facilitate maintainance. A script in Chrome OS would have many
dependencies on the Chromium script and it would be messy to maintain.
Changing the script in Chromium cannot break Chrome OS because it is
guarded by an uprev step in the protofiles project.
BUG=chromium:659020, chromium:659078
TEST=Compiled Chromium, tested autogenerated code in Chrome OS
Review-Url: https://codereview.chromium.org/2726103004
Cr-Commit-Position: refs/heads/master@{#460056}
Committed: https://chromium.googlesource.com/chromium/src/+/dc39ee6eb556261f1bcff11bf658eacea0ee4572
Patch Set 1 #
Total comments: 12
Patch Set 2 : Rebase #Patch Set 3 : Incorporated emaxx's comments. #Messages
Total messages: 19 (8 generated)
ljusten@chromium.org changed reviewers: + emaxx@chromium.org, pastarmovj@chromium.org
Sample generated code:
************************************************** .h
**************************************************
//
// DO NOT MODIFY THIS FILE DIRECTLY!
// IT IS GENERATED BY generate_policy_source.py
// FROM /build/enguarde/usr/share/policy_resources/policy_templates.json
//
#ifndef __BINDINGS_POLICY_CONSTANTS_H_
#define __BINDINGS_POLICY_CONSTANTS_H_
namespace enterprise_management {
class CloudPolicySettings;
class IntegerPolicyProto;
class BooleanPolicyProto;
class StringPolicyProto;
class StringListPolicyProto;
} // namespace enterprise_management
namespace policy {
// Registry key names for user and device policies.
namespace key {
extern const char kAdditionalLaunchParameters[];
extern const char kAllowCrossOriginAuthPrompt[];
...
} // namespace key
// Access to the mutable protobuf function of all supported integer user
// policies.
struct IntegerPolicyAccess {
const char* policy_key;
enterprise_management::IntegerPolicyProto*
(enterprise_management::CloudPolicySettings::*mutable_proto_ptr)();
};
extern const IntegerPolicyAccess kIntegerPolicyAccess[];
// Access to the mutable protobuf function of all supported boolean user
// policies.
struct BooleanPolicyAccess {
const char* policy_key;
enterprise_management::BooleanPolicyProto*
(enterprise_management::CloudPolicySettings::*mutable_proto_ptr)();
};
extern const BooleanPolicyAccess kBooleanPolicyAccess[];
// Access to the mutable protobuf function of all supported string user
// policies.
struct StringPolicyAccess {
const char* policy_key;
enterprise_management::StringPolicyProto*
(enterprise_management::CloudPolicySettings::*mutable_proto_ptr)();
};
extern const StringPolicyAccess kStringPolicyAccess[];
// Access to the mutable protobuf function of all supported stringlist user
// policies.
struct StringListPolicyAccess {
const char* policy_key;
enterprise_management::StringListPolicyProto*
(enterprise_management::CloudPolicySettings::*mutable_proto_ptr)();
};
extern const StringListPolicyAccess kStringListPolicyAccess[];
} // namespace policy
#endif // __BINDINGS_POLICY_CONSTANTS_H_
************************************************** .cc
**************************************************
//
// DO NOT MODIFY THIS FILE DIRECTLY!
// IT IS GENERATED BY generate_policy_source.py
// FROM /build/enguarde/usr/share/policy_resources/policy_templates.json
//
#include "bindings/cloud_policy.pb.h"
#include "bindings/policy_constants.h"
namespace em = enterprise_management;
namespace policy {
namespace key {
const char kAdditionalLaunchParameters[] = "AdditionalLaunchParameters";
const char kAllowCrossOriginAuthPrompt[] = "AllowCrossOriginAuthPrompt";
...
} // namespace key
constexpr IntegerPolicyAccess kIntegerPolicyAccess[] = {
{key::kArcCertificatesSyncMode,
&em::CloudPolicySettings::mutable_arccertificatessyncmode},
...
{key::kUserActivityScreenDimDelayScale,
&em::CloudPolicySettings::mutable_useractivityscreendimdelayscale},
{nullptr, nullptr},
};
constexpr BooleanPolicyAccess kBooleanPolicyAccess[] = {
{key::kAllowDinosaurEasterEgg,
&em::CloudPolicySettings::mutable_allowdinosaureasteregg},
...
{key::kWaitForInitialUserActivity,
&em::CloudPolicySettings::mutable_waitforinitialuseractivity},
{nullptr, nullptr},
};
constexpr StringPolicyAccess kStringPolicyAccess[] = {
{key::kAllowedDomainsForApps,
&em::CloudPolicySettings::mutable_alloweddomainsforapps},
...
{key::kWebRtcUdpPortRange,
&em::CloudPolicySettings::mutable_webrtcudpportrange},
{nullptr, nullptr},
};
constexpr StringListPolicyAccess kStringListPolicyAccess[] = {
{key::kAttestationExtensionWhitelist,
&em::CloudPolicySettings::mutable_attestationextensionwhitelist},
...
{key::kVideoCaptureAllowedUrls,
&em::CloudPolicySettings::mutable_videocaptureallowedurls},
{nullptr, nullptr},
};
} // namespace policy
LGTM with nits https://codereview.chromium.org/2726103004/diff/1/components/policy/tools/gen... File components/policy/tools/generate_policy_source.py (right): https://codereview.chromium.org/2726103004/diff/1/components/policy/tools/gen... components/policy/tools/generate_policy_source.py:1119: POLICY_DECODER_CPP_HEAD = ''' nit: Add word "CLOUD" into the constant names here and in line 1183 (for consistency with _WriteCloudPolicyDecoder)? https://codereview.chromium.org/2726103004/diff/1/components/policy/tools/gen... components/policy/tools/generate_policy_source.py:1210: def _WritePolicyDecoderCode(f, policy): nit: Add word "Cloud" into the function name (for consistency with _WriteCloudPolicyDecoder)? https://codereview.chromium.org/2726103004/diff/1/components/policy/tools/gen... components/policy/tools/generate_policy_source.py:1263: #------------------ Chrome OS policy constants header ------------------------# nit: Could you please reformat this bar and the other comment bars in the file to the same length? (Most of them are 69 characters long - for some reason :) ) https://codereview.chromium.org/2726103004/diff/1/components/policy/tools/gen... components/policy/tools/generate_policy_source.py:1267: return filter(lambda policy: policy.is_supported and \ nit: Backslash is not required. https://codereview.chromium.org/2726103004/diff/1/components/policy/tools/gen... components/policy/tools/generate_policy_source.py:1273: protobuf_types = set() nit: Maybe simply: return set(policy.policy_protobuf_type for policy in policies) https://codereview.chromium.org/2726103004/diff/1/components/policy/tools/gen... components/policy/tools/generate_policy_source.py:1295: def _WriteChromeOSPolicyConstantsHeader(policies, os, f, riskTags): nit: s/riskTags/risk_tags/ according to style guide (across the whole file?)
Thanks Maksim, I've incorporated your comments. Julian, can I go ahead and submit this? https://codereview.chromium.org/2726103004/diff/1/components/policy/tools/gen... File components/policy/tools/generate_policy_source.py (right): https://codereview.chromium.org/2726103004/diff/1/components/policy/tools/gen... components/policy/tools/generate_policy_source.py:1119: POLICY_DECODER_CPP_HEAD = ''' On 2017/03/02 16:56:15, emaxx wrote: > nit: Add word "CLOUD" into the constant names here and in line 1183 (for > consistency with > _WriteCloudPolicyDecoder)? Done. https://codereview.chromium.org/2726103004/diff/1/components/policy/tools/gen... components/policy/tools/generate_policy_source.py:1210: def _WritePolicyDecoderCode(f, policy): On 2017/03/02 16:56:15, emaxx wrote: > nit: Add word "Cloud" into the function name (for consistency with > _WriteCloudPolicyDecoder)? Done. https://codereview.chromium.org/2726103004/diff/1/components/policy/tools/gen... components/policy/tools/generate_policy_source.py:1263: #------------------ Chrome OS policy constants header ------------------------# On 2017/03/02 16:56:15, emaxx wrote: > nit: Could you please reformat this bar and the other comment bars in the file > to the same length? (Most of them are 69 characters long - for some reason :) ) Done. https://codereview.chromium.org/2726103004/diff/1/components/policy/tools/gen... components/policy/tools/generate_policy_source.py:1267: return filter(lambda policy: policy.is_supported and \ On 2017/03/02 16:56:15, emaxx wrote: > nit: Backslash is not required. Done. https://codereview.chromium.org/2726103004/diff/1/components/policy/tools/gen... components/policy/tools/generate_policy_source.py:1273: protobuf_types = set() On 2017/03/02 16:56:15, emaxx wrote: > nit: Maybe simply: > return set(policy.policy_protobuf_type for policy in policies) Done. https://codereview.chromium.org/2726103004/diff/1/components/policy/tools/gen... components/policy/tools/generate_policy_source.py:1295: def _WriteChromeOSPolicyConstantsHeader(policies, os, f, riskTags): On 2017/03/02 16:56:15, emaxx wrote: > nit: s/riskTags/risk_tags/ according to style guide (across the whole file?) Done.
Seems like you marked all comments as done but haven't uploaded a new patch-set?
Patchset #2 (id:20001) has been deleted
PTAL. I accidentally uploaded it to another Rietveld issue. Can't wait until we switch to Gerrit, one workflow to rule them all ;-)
lgtm
The CQ bit was checked by ljusten@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from emaxx@chromium.org Link to the patchset: https://codereview.chromium.org/2726103004/#ps60001 (title: "Incorporated emaxx's comments.")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_chromium_asan_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by ljusten@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch.
Bot data: {"patchset_id": 60001, "attempt_start_ts": 1490687335542000,
"parent_rev": "debb70fbd588bf22ae28d686e705ef27a3c123a5", "commit_rev":
"dc39ee6eb556261f1bcff11bf658eacea0ee4572"}
Message was sent while issue was closed.
Description was changed from ========== Generate code for encoding cloud policy protobufs Modifies the script that generates code from policy_templates.json to output policy code that make it easy to iterate over all user policies to encode data in a cloud policy protobuf. The code is not used in Chromium. It will be used in Chrome OS's authpolicy project. Right now, authpolicy uses similar, checked in code, see policy_keys and in user_policy_encoder_gen.cc platform2/authpolicy/policy. This CL is implemented in Chromium, as opposed to a script in Chrome OS, to facilitate maintainance. A script in Chrome OS would have many dependencies on the Chromium script and it would be messy to maintain. Changing the script in Chromium cannot break Chrome OS because it is guarded by an uprev step in the protofiles project. BUG=chromium:659020, chromium:659078 TEST=Compiled Chromium, tested autogenerated code in Chrome OS ========== to ========== Generate code for encoding cloud policy protobufs Modifies the script that generates code from policy_templates.json to output policy code that make it easy to iterate over all user policies to encode data in a cloud policy protobuf. The code is not used in Chromium. It will be used in Chrome OS's authpolicy project. Right now, authpolicy uses similar, checked in code, see policy_keys and in user_policy_encoder_gen.cc platform2/authpolicy/policy. This CL is implemented in Chromium, as opposed to a script in Chrome OS, to facilitate maintainance. A script in Chrome OS would have many dependencies on the Chromium script and it would be messy to maintain. Changing the script in Chromium cannot break Chrome OS because it is guarded by an uprev step in the protofiles project. BUG=chromium:659020, chromium:659078 TEST=Compiled Chromium, tested autogenerated code in Chrome OS Review-Url: https://codereview.chromium.org/2726103004 Cr-Commit-Position: refs/heads/master@{#460056} Committed: https://chromium.googlesource.com/chromium/src/+/dc39ee6eb556261f1bcff11bf658... ==========
Message was sent while issue was closed.
Committed patchset #3 (id:60001) as https://chromium.googlesource.com/chromium/src/+/dc39ee6eb556261f1bcff11bf658... |
