Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(846)

Issue 406993002: Validate incoming JS Message Headers

Created:
6 years, 5 months ago by hansmuller
Modified:
6 years, 5 months ago
CC:
abarth-chromium, Aaron Boodman, ben+mojo_chromium.org, chromium-reviews, darin (slow to review), qsr+mojo_chromium.org, viettrungluu+watch_chromium.org, yzshen+watch_chromium.org
Project:
chromium
Visibility:
Public.

Description

Validate incoming JS Message Headers This is an incremental step towards incoming message validation for JS in general. BUG=395801

Patch Set 1 #

Total comments: 21
Unified diffs Side-by-side diffs Delta from patch set Stats (+787 lines, -10 lines) Patch
A + mojo/bindings/js/file_io.h View 2 chunks +7 lines, -5 lines 0 comments Download
A mojo/bindings/js/file_io.cc View 1 chunk +71 lines, -0 lines 8 comments Download
A mojo/bindings/js/message_file_parser.js View 1 chunk +564 lines, -0 lines 4 comments Download
M mojo/bindings/js/run_js_tests.cc View 4 chunks +15 lines, -2 lines 0 comments Download
A mojo/bindings/js/validation_unittests.js View 1 chunk +42 lines, -0 lines 0 comments Download
M mojo/mojo.gyp View 1 chunk +2 lines, -0 lines 0 comments Download
M mojo/public/js/bindings/codec.js View 3 chunks +19 lines, -1 line 0 comments Download
M mojo/public/js/bindings/router.js View 2 chunks +8 lines, -2 lines 2 comments Download
A mojo/public/js/bindings/validator.js View 1 chunk +59 lines, -0 lines 7 comments Download

Messages

Total messages: 5 (0 generated)
hansmuller
Most of this patch's bulk is the test message ".data" parser and its internal tests. ...
6 years, 5 months ago (2014-07-21 22:50:59 UTC) #1
yzshen1
On 2014/07/21 22:50:59, hansmuller wrote: > Most of this patch's bulk is the test message ...
6 years, 5 months ago (2014-07-21 23:41:16 UTC) #2
hansmuller
On 2014/07/21 23:41:16, yzshen1 wrote: > On 2014/07/21 22:50:59, hansmuller wrote: > > Most of ...
6 years, 5 months ago (2014-07-22 00:13:53 UTC) #3
abarth-chromium
https://codereview.chromium.org/406993002/diff/1/mojo/bindings/js/file_io.cc File mojo/bindings/js/file_io.cc (right): https://codereview.chromium.org/406993002/diff/1/mojo/bindings/js/file_io.cc#newcode15 mojo/bindings/js/file_io.cc:15: #include "mojo/public/cpp/test_support/test_support.h" This module shouldn't need anything from Mojo. ...
6 years, 5 months ago (2014-07-22 03:51:01 UTC) #4
hansmuller
6 years, 5 months ago (2014-07-22 15:49:07 UTC) #5
I'm breaking this CL into 3 parts per Yuzhu's feedback and will include the
changes you suggested.

https://codereview.chromium.org/406993002/diff/1/mojo/bindings/js/file_io.cc
File mojo/bindings/js/file_io.cc (right):

https://codereview.chromium.org/406993002/diff/1/mojo/bindings/js/file_io.cc#...
mojo/bindings/js/file_io.cc:15: #include
"mojo/public/cpp/test_support/test_support.h"
On 2014/07/22 03:51:00, abarth wrote:
> This module shouldn't need anything from Mojo.  I can be in //gin/test

I'm loading mojo data files from a source relative pathname and so I used
test::OpenSourceRootRelativeFile(). It looks like I can get the root "src"
pathname from  PathService::Get(base::DIR_SOURCE_ROOT, &path). I could add
support for looking up the root src path to a //gin/test FileIO module as well,
and eliminate this dependency.

https://codereview.chromium.org/406993002/diff/1/mojo/bindings/js/file_io.cc#...
mojo/bindings/js/file_io.cc:43: size_t size_read = fread(&result.at(0), 1, size,
fp);
On 2014/07/22 03:51:00, abarth wrote:
> I thought there was a function in base that did all this work for you.

You are correct: base::ReadFileToString(). I'll use that here.

https://codereview.chromium.org/406993002/diff/1/mojo/bindings/js/file_io.cc#...
mojo/bindings/js/file_io.cc:51: gin::WrapperInfo g_wrapper_info = {
gin::kEmbedderNativeGin };
On 2014/07/22 03:51:00, abarth wrote:
> Bad indent
Will fix.

https://codereview.chromium.org/406993002/diff/1/mojo/bindings/js/file_io.cc#...
mojo/bindings/js/file_io.cc:55: const char FileIO::kModuleName[] =
"mojo/public/js/bindings/fileio";
On 2014/07/22 03:51:00, abarth wrote:
> This path should match the location of the C++ code.  In particular, this
module
> isn't part of the public API and therefore should not have "public" in its
name.

OK. And if I'm reading you correctly, the FileIO module should end up in
gin/test, not in mojo at all.

https://codereview.chromium.org/406993002/diff/1/mojo/bindings/js/message_fil...
File mojo/bindings/js/message_file_parser.js (right):

https://codereview.chromium.org/406993002/diff/1/mojo/bindings/js/message_fil...
mojo/bindings/js/message_file_parser.js:9: ], function (console, expect, fileio)
{
On 2014/07/22 03:51:00, abarth wrote:
> If this module is for testing, should it be in a "test" directory?

Do you mean a test subdirectory below /mojo/bindings/js? Should the unit tests
from this directory move there as well?

https://codereview.chromium.org/406993002/diff/1/mojo/bindings/js/message_fil...
mojo/bindings/js/message_file_parser.js:19: })();
On 2014/07/22 03:51:00, abarth wrote:
> This code looks copy/pasted from codec.js.  Should we factor it into a module
so
> they can share?

Yes. I'd wanted to do as much in a separate CL since it will impact the classes
in codec.js as well.

https://codereview.chromium.org/406993002/diff/1/mojo/public/js/bindings/rout...
File mojo/public/js/bindings/router.js (right):

https://codereview.chromium.org/406993002/diff/1/mojo/public/js/bindings/rout...
mojo/public/js/bindings/router.js:6: "console",
On 2014/07/22 03:51:00, abarth wrote:
> Production code shouldn't use |console|

OK, I'll remove that.

https://codereview.chromium.org/406993002/diff/1/mojo/public/js/bindings/vali...
File mojo/public/js/bindings/validator.js (right):

https://codereview.chromium.org/406993002/diff/1/mojo/public/js/bindings/vali...
mojo/public/js/bindings/validator.js:5:
define("mojo/public/js/bindings/validator", [
On 2014/07/22 03:51:00, abarth wrote:
> No need to name the module.  The module loader will imply the name from the
> path.
OK.

https://codereview.chromium.org/406993002/diff/1/mojo/public/js/bindings/vali...
mojo/public/js/bindings/validator.js:25: })();
On 2014/07/22 03:51:00, abarth wrote:
> Why not just write out the code?  It seems unnecessary to do all this work at
> module load time.

Sorry, I got carried away. I'll write out the constants (which should address
the other comments about this enum.

Powered by Google App Engine
This is Rietveld 408576698