-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C#: Models as Data Documentation #15563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C#: Models as Data Documentation #15563
Conversation
4d31893
to
4e75726
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for writing this up. Some comments.
docs/codeql/codeql-language-guides/customizing-library-models-for-csharp.rst
Outdated
Show resolved
Hide resolved
About data extensions | ||
--------------------- | ||
|
||
You can customize analysis by defining models (summaries, sinks, and sources) of your code's C#/.NET dependencies in data extension files. Each model defines the behavior of one or more elements of your library or framework, such as methods, properties, and callables. When you run dataflow analysis, these models expand the potential sources and sinks tracked by dataflow analysis and improve the precision of results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
customize analysis
-> customize analyses
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And dataflow analysis
-> dataflow analyses
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure which is better, but that wording is taken from the Java customizing-library-models docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think analyses
is probably better in both contexts, but I don't think the gain in clarity is enough to justify making edits here and in the Java docs, since "analysis" does also technically make sense (at least I think it does!), and it wouldn't just affect this paragraph.
docs/codeql/codeql-language-guides/customizing-library-models-for-csharp.rst
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
We need to add a tuple to the ``sinkModel``\(namespace, type, subtypes, name, signature, ext, input, kind, provenance) extensible predicate by updating a data extension file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with .rst
syntax, but the above looks wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, that looks weird to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if we think that it's fine to highlight the entirety of sinkModel(namespace, ..., I can change it over.
I think this would probably would be best, but it would involve numerous edits to both this documentation and the Java documentation. If you have time to do this, it'd be great, but it's not urgent 👍
docs/codeql/codeql-language-guides/customizing-library-models-for-csharp.rst
Show resolved
Hide resolved
docs/codeql/codeql-language-guides/customizing-library-models-for-csharp.rst
Outdated
Show resolved
Hide resolved
docs/codeql/codeql-language-guides/customizing-library-models-for-csharp.rst
Outdated
Show resolved
Hide resolved
docs/codeql/codeql-language-guides/customizing-library-models-for-csharp.rst
Outdated
Show resolved
Hide resolved
docs/codeql/codeql-language-guides/customizing-library-models-for-csharp.rst
Outdated
Show resolved
Hide resolved
docs/codeql/codeql-language-guides/customizing-library-models-for-csharp.rst
Outdated
Show resolved
Hide resolved
docs/codeql/codeql-language-guides/customizing-library-models-for-csharp.rst
Outdated
Show resolved
Hide resolved
docs/codeql/codeql-language-guides/customizing-library-models-for-csharp.rst
Show resolved
Hide resolved
docs/codeql/codeql-language-guides/customizing-library-models-for-csharp.rst
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@egregius313 : Really good examples!
It would be great, if we could also make something similar to extensible-predicates.rst
which is currently java specific (and for some reason not linked from the java documentation).
d95c5f8
to
18465d8
Compare
@michaelnebel The existing |
That is an excellent question! That is, if you want to do more examples, then the order of "importance" is probably:
You are more than welcome to add more examples - this would be highly appreciated (I do know this is scope creep, but it would be really valuable, if we had these examples), but not strictly required I think. |
@michaelnebel I am going to work on extensible-predicate, but in order to avoid scope-creep in this PR, I am going to do those updates in a separate PR. It will make it easier to make sure this is reviewed and ready to merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Only minor and super minor (purely docs) comments. This is very clear and matches the Java docs really well.
} | ||
} | ||
|
||
We need to add a tuple to the ``sinkModel``\(namespace, type, subtypes, name, signature, ext, input, kind, provenance) extensible predicate by updating a data extension file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if we think that it's fine to highlight the entirety of sinkModel(namespace, ..., I can change it over.
I think this would probably would be best, but it would involve numerous edits to both this documentation and the Java documentation. If you have time to do this, it'd be great, but it's not urgent 👍
About data extensions | ||
--------------------- | ||
|
||
You can customize analysis by defining models (summaries, sinks, and sources) of your code's C#/.NET dependencies in data extension files. Each model defines the behavior of one or more elements of your library or framework, such as methods, properties, and callables. When you run dataflow analysis, these models expand the potential sources and sinks tracked by dataflow analysis and improve the precision of results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think analyses
is probably better in both contexts, but I don't think the gain in clarity is enough to justify making edits here and in the Java docs, since "analysis" does also technically make sense (at least I think it does!), and it wouldn't just affect this paragraph.
docs/codeql/codeql-language-guides/customizing-library-models-for-csharp.rst
Outdated
Show resolved
Hide resolved
docs/codeql/codeql-language-guides/customizing-library-models-for-java-and-kotlin.rst
Outdated
Show resolved
Hide resolved
docs/codeql/codeql-language-guides/customizing-library-models-for-csharp.rst
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Co-authored-by: Michael Nebel <michaelnebel@github.com>
Co-authored-by: Ben Ahmady <32935794+subatoi@users.noreply.github.com>
be4c14d
to
c5dbaa6
Compare
@michaelnebel not from me from a Docs point of view 👍 |
@michaelnebel Sorry for the late thought: it occurred to us to check this is due to ship with CLI 2.16.3. If so, all good 👍 Edit: 2.16.4, apologies |
Alright thank you! |
- The second value ``SqlCommand`` is the name of the class (type) that contains the method. | ||
- The third value ``False`` is a flag that indicates whether or not the sink also applies to all overrides of the method. | ||
- The fourth value ``SqlCommand`` is the method name. Constructors are named after the class. | ||
- The fifth value ``(System.String,System.Data.SqlClient.SqlConnection)`` is the method input type signature. The type names must be fully qualified. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type names must be fully qualified.
More curiosity than an actual problem, but why does C# require fully qualified names, but Java doesn't?
Introduces Models-as-Data documentation for C#
Later follow-up will be to add the threat modeling documentation.