summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authortira-misu <gunter.burchardt@boschrexroth.de>2023-04-06 00:29:14 +0200
committerGitHub <noreply@github.com>2023-04-06 00:29:14 +0200
commit876a64aae138be5d9eb9245348719a18161d8e09 (patch)
tree14940818e1a6506eeb180150d610e41a06735732 /docs
parent2803983c708ff6f4861c324597fd8e5f74660f67 (diff)
downloadflatbuffers-876a64aae138be5d9eb9245348719a18161d8e09.tar.gz
flatbuffers-876a64aae138be5d9eb9245348719a18161d8e09.tar.bz2
flatbuffers-876a64aae138be5d9eb9245348719a18161d8e09.zip
[CS] Verifier (#7850)
* Fix C/C++ Create<Type>Direct with sorted vectors If a struct has a key the vector has to be sorted. To sort the vector you can't use "const". * Changes due to code review * Improve code readability * Add generate of JSON schema to string to lib * option indent_step is supported * Remove unused variables * Fix break in test * Fix style to be consistent with rest of the code * [TS] Fix reserved words as arguments (#6955) * [TS] Fix generation of reserved words in object api (#7106) * [TS] Fix generation of object api * [TS] Fix MakeCamel -> ConvertCase * [C#] Fix collision of field name and type name * [TS] Add test for struct of struct of struct * Update generated files * Add missing files * [TS] Fix query of null/undefined fields in object api * Add .Net verfier * Add some fuzz tests for .Net * Remove additional files * Fix .net test * Changes due to PR * Fix generated files --------- Co-authored-by: Derek Bailey <derekbailey@google.com>
Diffstat (limited to 'docs')
-rw-r--r--docs/source/CsharpUsage.md41
-rw-r--r--docs/source/doxyfile3
2 files changed, 43 insertions, 1 deletions
diff --git a/docs/source/CsharpUsage.md b/docs/source/CsharpUsage.md
index da36fa8b..b0acc77d 100644
--- a/docs/source/CsharpUsage.md
+++ b/docs/source/CsharpUsage.md
@@ -142,6 +142,47 @@ To use it:
`ByKey` only works if the vector has been sorted, it will
likely not find elements if it hasn't been sorted.
+## Buffer verification
+
+As mentioned in [C++ Usage](@ref flatbuffers_guide_use_cpp) buffer
+accessor functions do not verify buffer offsets at run-time.
+If it is necessary, you can optionally use a buffer verifier before you
+access the data. This verifier will check all offsets, all sizes of
+fields, and null termination of strings to ensure that when a buffer
+is accessed, all reads will end up inside the buffer.
+
+Each root type will have a verification function generated for it,
+e.g. `Monster.VerifyMonster`. This can be called as shown:
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cs}
+ var ok = Monster.VerifyMonster(buf);
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+if `ok` is true, the buffer is safe to read.
+
+For a more detailed control of verification `MonsterVerify.Verify`
+for `Monster` type can be used:
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cs}
+ # Sequence of calls
+ FlatBuffers.Verifier verifier = new FlatBuffers.Verifier(buf);
+ var ok = verifier.VerifyBuffer("MONS", false, MonsterVerify.Verify);
+
+ # Or single line call
+ var ok = new FlatBuffers.Verifier(bb).setStringCheck(true).\
+ VerifyBuffer("MONS", false, MonsterVerify.Verify);
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+if `ok` is true, the buffer is safe to read.
+
+A second parameter of `verifyBuffer` specifies whether buffer content is
+size prefixed or not. In the example above, the buffer is assumed to not include
+size prefix (`false`).
+
+Verifier supports options that can be set using appropriate fluent methods:
+* SetMaxDepth - limit the nesting depth. Default: 1000000
+* SetMaxTables - total amount of tables the verifier may encounter. Default: 64
+* SetAlignmentCheck - check content alignment. Default: True
+* SetStringCheck - check if strings contain termination '0' character. Default: true
+
+
## Text parsing
There currently is no support for parsing text (Schema's and JSON) directly
diff --git a/docs/source/doxyfile b/docs/source/doxyfile
index 8cf9000d..9541aaff 100644
--- a/docs/source/doxyfile
+++ b/docs/source/doxyfile
@@ -779,7 +779,8 @@ INPUT = "FlatBuffers.md" \
"../../python/flatbuffers/builder.py" \
"../../js/flatbuffers.js" \
"../../php/FlatbufferBuilder.php" \
- "../../net/FlatBuffers/FlatBufferBuilder.cs" \
+ "../../net/FlatBuffers/FlatBufferBuilder.cs"
+ "../../net/FlatBuffers/FlatBufferVerify.cs" \
"../../include/flatbuffers/flatbuffers.h" \
"../../go/builder.go" \
"../../rust/flatbuffers/src/builder.rs"