FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

16 cryptography models libraries and queries migration by ropwareJB · Pull Request #14289 · github/codeql · GitHub

/ codeql Public

16 cryptography models libraries and queries migration - #14289

Merged
RasmusWL merged 13 commits into
github:mainfrom
microsoft:jb1/16-cryptography-models-libraries-and-queries-migration
Oct 4, 2023
Merged

16 cryptography models libraries and queries migration#14289
RasmusWL merged 13 commits into
github:mainfrom
microsoft:jb1/16-cryptography-models-libraries-and-queries-migration

Conversation

Copy link
Copy Markdown
Contributor

Rebased microsoft#17 onto upstream/main.

@bdrodes:

Migration of C/C++ crypto models, inventory queries and example alerts.

github-advanced-security AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

CodeQL found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.

sidshank requested a review from RasmusWL September 27, 2023 19:38
RasmusWL previously approved these changes Sep 28, 2023

RasmusWL left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

File layout 👍 for Python (did not review actual QL code yet)

Thanks for removing security tags for now, we should remember to add them when we want to publish these queries 😅 (I requested this to happen offline)

jketema left a comment
edited
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The C++ file-layout generally looks ok to me. However, the split between inventory/new_models and inventory/old_models eludes me, especially since inventory/old_models is empty. What is the purpose of this?

Also per our contributing guide, all the queries will need to be tagged with the experimental tag, which seems to be missing ("Experimental queries need to include experimental in their @tags").

I'm also slightly concerned by the lack of tests.

Copy link
Copy Markdown
Contributor

The security and experimental tags has been deliberately removed to avoid any risk of these queries to be included in the experimental query suite.

bdrodes commented Sep 28, 2023

Copy link
Copy Markdown
Contributor

The C++ file-layout generally looks ok to me. However, the split between inventory/new_models and inventory/old_models eludes me, especially since inventory/old_models is empty. What is the purpose of this?

Also per our contributing guide, all the queries will need to be tagged with the experimental tag, which seems to be missing ("Experimental queries need to include experimental in their @tags").

I'm also slightly concerned by the lack of tests.

The new vs old models exists to keep consistency with each language. For CPP we don't have old models, but I also haven't done a deep dive to try to artificially create some. It's also possible I missed some.

The tags were removed by request to avoid automatic pack inclusion.

We have tests for some of sample alerts internally to Microsoft, but the point of these was to be examples, but we can definitely get tests for these. In terms of the CBOM queries, for this initial push, the focus was on getting our queries into a public space. I expect the underlying models will change and what is being alerted on might change in the near future as well, so our intent was that tests would be developed in the near future for these queries. In fact, we are currently figuring out what test means for bill of material queries as part of this effort (@pwntester is currently running cbom queries on various public repos). My thought was a test should compare the new vs old models so we have something to compare against for regression, which I believe is what @pwntester is currently experimenting with.

jketema commented Sep 28, 2023

Copy link
Copy Markdown
Contributor

The new vs old models exists to keep consistency with each language. For CPP we don't have old models, but I also haven't done a deep dive to try to artificially create some. It's also possible I missed some.

That doesn't really tell me a lot. What's the purpose the the "old" models? Taking the word "old" face-value it's sound like something out dated that we do not want in the repo.

bdrodes commented Sep 28, 2023
edited
Loading

Copy link
Copy Markdown
Contributor

The new vs old models exists to keep consistency with each language. For CPP we don't have old models, but I also haven't done a deep dive to try to artificially create some. It's also possible I missed some.

That doesn't really tell me a lot. What's the purpose the "old" models? Taking the word "old" face-value it's sound like something out dated that we do not want in the repo.

In some languages there are existing models for cryptography, either partial or mature. Where those exist, we develop queries for CBOM using those models we call them "old" models compared to the current PQC bill of material effort. Queries built upon any new modeling for that purposes of PQC we are calling "new".

jketema commented Sep 28, 2023
edited
Loading

Copy link
Copy Markdown
Contributor

The new vs old models exists to keep consistency with each language. For CPP we don't have old models, but I also haven't done a deep dive to try to artificially create some. It's also possible I missed some.

That doesn't really tell me a lot. What's the purpose the "old" models? Taking the word "old" face-value it's sound like something out dated that we do not want in the repo.

In some languages there are existing models for cryptography, either partial or mature. Where those exist, we develop queries for CBOM using those models we call them "old" models compared to the current PQC bill of material effort. Queries built upon any new modeling for that purposes of PQC we are calling "new".

That still doesn't help a lot. Are the old models ours or yours? If they're ours they will be located somewhere else already, and a copy seems unnecessary. If they're yours, why should we become responsible for maintaining something that still sounds like it's outdated?

bdrodes commented Sep 28, 2023
edited
Loading

Copy link
Copy Markdown
Contributor

The queries in these directories are 'inventory' queries (as indicated by the parent directory). They are sub-categorized by if the inventory query uses an existing (older) model for crypto (which we simply import from the part of the repo it already exists in) or it uses a newer model developed for this PQC effort specifically (in which case the crypto models are in this PR).

The confusion is that the name of the directory is giving the impression that it contains crypto models. It does not, it contains inventory queries using existing crypto models (just calling them old, but 'classic' might be a better word) or new models.

jketema commented Sep 28, 2023

Copy link
Copy Markdown
Contributor

Thanks for the clarification. I think there's a discussion to be had - at a later moment - as to whether we should have all these inventory queries, but the file-layout looks good as-is.

sidshank marked this pull request as ready for review October 3, 2023 20:22
sidshank requested review from a team as code owners October 3, 2023 20:22

aeisenberg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'm generally fine with this. I haven't looked at the queries in detail. I'll trust the review of @RasmusWL and @jketema.

There is a lot of commented out code. I'd prefer that either the code is deleted, or there is a clear reason why the commented code should remain.

Also, there is a code scanning warning about using camel case of OpenSSL. I'm find either way.

import experimental.cryptography.CryptoArtifact
import experimental.cryptography.CryptoAlgorithmNames

import experimental.cryptography.modules.OpenSSL as OpenSSL

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

For consistency with other names, can you change this to `OpenSsl


abstract class CryptographicArtifact extends Expr { }

// /**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Any reason why this is commented out? Can you please include a comment explaining why, and why it is important to leave in, or else delete it.


abstract string getAlgType();

// string getAlgType(){

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Same as above.

import experimental.cryptography.utils.OpenSSL.PassthroughFunction
import experimental.cryptography.utils.OpenSSL.CryptoAlgorithm
import experimental.cryptography.CryptoArtifact
// import semmle.code.cpp.ir.dataflow.TaintTracking

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Delete

aeisenberg previously approved these changes Oct 3, 2023

aeisenberg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Approving, assuming that the code can be cleaned up in a followup.

RasmusWL left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

As I said previously

File layout 👍 for Python (did not review actual QL code yet)

Thanks for removing security tags for now, we should remember to add them when we want to publish these queries 😅 (I requested this to happen offline)

RasmusWL merged commit 9c02b4f into github:main Oct 4, 2023
ropwareJB deleted the jb1/16-cryptography-models-libraries-and-queries-migration branch October 4, 2023 16:23
ropwareJB pushed a commit to microsoft/codeql that referenced this pull request Oct 4, 2023
…dels-libraries-and-queries-migration

16 cryptography models libraries and queries migration
bdrodes pushed a commit to microsoft/codeql that referenced this pull request Oct 4, 2023
…dels-libraries-and-queries-migration (#19)

16 cryptography models libraries and queries migration

Co-authored-by: Rasmus Wriedt Larsen <rasmuswl@github.com>
bdrodes pushed a commit to microsoft/codeql that referenced this pull request Feb 6, 2026
…dels-libraries-and-queries-migration (#19)

16 cryptography models libraries and queries migration

Co-authored-by: Rasmus Wriedt Larsen <rasmuswl@github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants


Back | FazBrowse Home | New Git URL