openenclave / oeedger8r-cpp

An implementation of oeedger8r in C++
MIT License
8 stars 13 forks source link

Validate attributes #49

Closed anakrish closed 4 years ago

anakrish commented 4 years ago

Add validation for attributes supported by oeedger8r. Lockdown with tests.

Signed-off-by: Anand Krishnamoorthi anakrish@microsoft.com

mingweishih commented 4 years ago

For the case of adding attribute to the edl-annotated struct, it's required to have the count attribute be defined. Can we also error out the case that count is missing?

For example, we should error out the following case.

  struct DeepCopy
  {
    size_t size;
    [size=size] char *buf;
  };

...

void ocall_test([in, out] DeepCopy *dc)

Otherwise, there will be a compilation error:

/home/ssh_office/workspace/oeedger8r-cpp/build/test/null_check/enc/null_check_t.c:1020:38: error: expected expression before ‘;’ token
         for (size_t _i_1 = 0; _i_1 < ; _i_1++)`.
anakrish commented 4 years ago

For the case of adding attribute to the edl-annotated struct, it's required to have the count attribute be defined. Can we also error out the case that count is missing?

For example, we should error out the following case.

  struct DeepCopy
  {
    size_t size;
    [size=size] char *buf;
  };

...

void ocall_test([in, out] DeepCopy *dc)

Otherwise, there will be a compilation error:

/home/ssh_office/workspace/oeedger8r-cpp/build/test/null_check/enc/null_check_t.c:1020:38: error: expected expression before ‘;’ token
         for (size_t _i_1 = 0; _i_1 < ; _i_1++)`.

@mingweishih That looks like a bug as opposed to a missing validation. Let me address that in a separate PR.

anakrish commented 4 years ago

@mingweishih I have addressed all PR feedback. Can you take another look? Note: Added in_function_ and in_struct_. parser state variables instead of passing flags.

oe-ci-robot commented 4 years ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: anakrish, mingweishih

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/openenclave/oeedger8r-cpp/blob/master/OWNERS)~~ [anakrish,mingweishih] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment