Compare commits

..

60 Commits

Author SHA1 Message Date
Arthur Baars
3990d0e11a Merge pull request #17808 from github/release-prep/2.19.2
Release preparation for version 2.19.2
2024-10-18 17:36:23 +02:00
Arthur Baars
aaf220d41e Fix typos in changelogs 2024-10-18 15:28:05 +00:00
github-actions[bot]
ca0345324e Release preparation for version 2.19.2 2024-10-18 15:16:21 +00:00
Arthur Baars
7c15be1f02 Merge pull request #17806 from github/revert-17764-release-prep/2.19.2
Revert "Release preparation for version 2.19.2"
2024-10-18 17:13:50 +02:00
Arthur Baars
eb515f884b Revert "Release preparation for version 2.19.2" 2024-10-18 17:06:20 +02:00
yoff
8cb339aa93 Merge pull request #17801 from yoff/python/extra-std-models
Python: extra modelling of stdlib
2024-10-18 15:32:01 +02:00
Rasmus Lerchedahl Petersen
30e5a12230 Python: udate expectations 2024-10-18 15:14:51 +02:00
Rasmus Lerchedahl Petersen
30053da70d Python: extra modelling of stdlib
as a reaction to the latest QA run
2024-10-18 13:49:33 +02:00
Paolo Tranquilli
5b2eb88672 Merge pull request #17766 from github/aibaars/fix-cwe-link
Fix CWE coverage link in main index
2024-10-15 14:05:50 +02:00
Arthur Baars
af6fc676ce Fix CWE coverage link in main index 2024-10-15 13:34:38 +02:00
Arthur Baars
15bc417a17 Merge pull request #17764 from github/release-prep/2.19.2
Release preparation for version 2.19.2
2024-10-15 13:08:40 +02:00
Arthur Baars
9ba8045837 Fix typos in changelog entries 2024-10-15 11:06:20 +00:00
github-actions[bot]
255f55cf1a Release preparation for version 2.19.2 2024-10-15 10:29:25 +00:00
Owen Mansel-Chan
1626af0ae1 Merge pull request #17748 from owen-mc/go/join-order-fix/data-flow-node-gettype
Go: Fix bad join order in `SummarizedParameterNode.gettype`
2024-10-15 10:14:38 +01:00
Geoffrey White
7d9a3e1399 Merge pull request #17756 from geoffw0/unusedvar6
Rust: More test cases for rust/unused-variable
2024-10-15 10:02:37 +01:00
Arthur Baars
508e8157b3 Merge pull request #17746 from github/aibaars/macro-pat-irrefutable
Rust: add MacroPat to isExhaustiveMatch
2024-10-15 10:45:06 +02:00
Geoffrey White
5e33d9a145 Rust: Further changes from code review. 2024-10-15 09:38:17 +01:00
Geoffrey White
8169ccd21e Apply suggestions from code review
Co-authored-by: Simon Friis Vindum <paldepind@github.com>
2024-10-15 09:36:09 +01:00
Simon Friis Vindum
cc1e33fb64 Merge pull request #17713 from hvitved/rust/ssa
Rust: Initial SSA implementation
2024-10-15 09:59:48 +02:00
Geoffrey White
57875554f4 Rust: Accept consistency failures in the new test cases. 2024-10-14 17:06:55 +01:00
Geoffrey White
e5885f65db Rust: Add more test cases for unused variables and unreachable code. 2024-10-14 16:25:18 +01:00
Geoffrey White
528641c55a Rust: Test spacing. 2024-10-14 16:25:17 +01:00
Geoffrey White
134539060d Rust: correct some 'spurious' annotations that are off by one line. 2024-10-14 16:24:44 +01:00
Geoffrey White
25b592fc89 Merge pull request #17744 from geoffw0/unusedvar5
Rust: Unused variable follow-up work
2024-10-14 16:20:52 +01:00
Taus
5115216c2d Merge pull request #17755 from github/python/more-adj
python: more adjustments...
2024-10-14 17:16:16 +02:00
yoff
da5e9ac18c python: more adjustments... 2024-10-14 14:54:33 +00:00
Edward Minnix III
ade5686e52 Merge pull request #17335 from egregius313/egregius313/go/dataflow/models/stdin
Go: Implement `stdin` models
2024-10-14 10:38:27 -04:00
Taus
96ea9507a4 Merge pull request #17754 from github/python/extractor-expectations
python: update extractor expectations
2024-10-14 16:35:06 +02:00
yoff
9d8d7ab237 python: update extractor expectations 2024-10-14 14:14:40 +00:00
Arthur Baars
ae7afa7aff Update rust/ql/lib/codeql/rust/controlflow/internal/Completion.qll
Co-authored-by: Simon Friis Vindum <simonfv@gmail.com>
2024-10-14 15:20:43 +02:00
Arthur Baars
867c8a7fa6 Merge branch 'main' into aibaars/macro-pat-irrefutable 2024-10-14 15:02:28 +02:00
Simon Friis Vindum
ef1592fe32 Merge pull request #17751 from paldepind/rust-rename-predicate
Rust: Rename isIrrefutablePattern to isExhaustiveMatch
2024-10-14 14:47:15 +02:00
Arthur Baars
493a68a232 Rust: add MacroPat to isExhaustiveMatch 2024-10-14 13:55:59 +02:00
Simon Friis Vindum
22261c1480 Rust: Rename isIrrefutablePattern to isExhaustiveMatch 2024-10-14 13:43:57 +02:00
Simon Friis Vindum
d0f978d937 Merge pull request #17749 from paldepind/rust-cfg-handle-question-mark
Rust: Handle question mark operator in CFG
2024-10-14 13:19:46 +02:00
Arthur Baars
de612963de Merge pull request #17750 from yoff/python/extractor-test-expectaionts
Python: adjust test expectations for extractor test
2024-10-14 12:54:15 +02:00
Rasmus Lerchedahl Petersen
3402a729d0 Python: adjust test expectations for extractor test 2024-10-14 12:36:56 +02:00
Simon Friis Vindum
e83f1d17bf Rust: Simplify return implementation in CFG 2024-10-14 11:40:35 +02:00
Simon Friis Vindum
8e4e663739 Rust: Handle question mark operator in CFG 2024-10-14 11:38:35 +02:00
Simon Friis Vindum
2f07f1c730 Rust: Abnormal completion in scrutinee does not continue to match arms 2024-10-14 11:32:22 +02:00
Simon Friis Vindum
23ee7b955c Rust: Add CFG tests for question mark operator and scrutinee with return 2024-10-14 11:27:32 +02:00
Owen Mansel-Chan
1456ec2119 Fix bad join order in SummarizedParameterNode.gettype
Specifically the disjunct for this.getPos() != -1. Running on
uber/aresdb, before we had this:

   2403   ~1%    {3} r6 = JOIN `DataFlowUtil::SummarizedParameterNode.getPos/0#dispred#70a2aab4` WITH `DataFlowPrivate::FlowSummaryNode.getSummarizedCallable/0#dispred#e79ea9be` ON FIRST 1 OUTPUT Lhs.1, Lhs.0, Rhs.1
9149774   ~5%    {4}    | JOIN WITH `Types::SignatureType.getParameterType/1#dispred#2c11bb7b_102#join_rhs` ON FIRST 1 OUTPUT Lhs.2, Rhs.1, Lhs.1, Rhs.2
    923   ~9%    {2}    | JOIN WITH `Scopes::Callable.getType/0#dispred#55a0e6a2` ON FIRST 2 OUTPUT Lhs.2, Lhs.3

We add a binding pragma to make it not bind on this.getPos() until
necessary. After we have this:

   2403   ~0%    {3} r6 = JOIN `DataFlowUtil::SummarizedParameterNode.getPos/0#dispred#70a2aab4` WITH `DataFlowPrivate::FlowSummaryNode.getSummarizedCallable/0#dispred#e79ea9be` ON FIRST 1 OUTPUT Rhs.1, Lhs.0, Lhs.1
   2373   ~0%    {3}    | JOIN WITH `Scopes::Callable.getType/0#dispred#55a0e6a2` ON FIRST 1 OUTPUT Rhs.1, Lhs.2, Lhs.1
    923   ~9%    {2}    | JOIN WITH `Types::SignatureType.getParameterType/1#dispred#2c11bb7b` ON FIRST 2 OUTPUT Lhs.2, Rhs.2
2024-10-13 14:27:51 +01:00
Tom Hvitved
6290be2922 Rust: Initial SSA implementation 2024-10-11 19:39:28 +02:00
Tom Hvitved
b0ea175021 Rust: Add more variables tests 2024-10-11 19:36:04 +02:00
yoff
8f681154ce Merge pull request #17683 from yoff/python/flip-default-for-stdlib-extraction
Python: Flip default for stdlib extraction
2024-10-11 18:34:44 +02:00
Geoffrey White
c4256f21c7 Rust: Fix out-of-date spurious tags. 2024-10-11 17:18:41 +01:00
Rasmus Lerchedahl Petersen
5650694313 Python: update tests 2024-10-11 15:36:44 +02:00
Rasmus Lerchedahl Petersen
e2eb08b543 Python: improve messaging 2024-10-11 15:36:44 +02:00
Rasmus Lerchedahl Petersen
22588c9f85 Python: update ectractor version 2024-10-11 15:36:44 +02:00
Rasmus Lerchedahl Petersen
c013d4a59c Python: update test expectations 2024-10-11 15:36:44 +02:00
Rasmus Lerchedahl Petersen
4a291147e0 Python: only look for the py2 stdlib if we extract std lib 2024-10-11 15:36:44 +02:00
Rasmus Lerchedahl Petersen
bb78c2a67e Python: update test expectations 2024-10-11 15:36:44 +02:00
Rasmus Lerchedahl Petersen
e91efaa92e python: do not extract stdlib by default 2024-10-11 15:36:44 +02:00
Edward Minnix III
0abc0d1a67 Fix: ActiveThreatModelSource 2024-10-09 11:35:07 -04:00
Ed Minnix
f8335e6163 Fix formatting 2024-10-01 15:58:07 -04:00
Edward Minnix III
91b7a6cbd8 Wording of change note
Co-authored-by: Owen Mansel-Chan <62447351+owen-mc@users.noreply.github.com>
2024-10-01 15:56:43 -04:00
Edward Minnix III
1f932d407f Remove unnecessary asExpr()
Co-authored-by: Owen Mansel-Chan <62447351+owen-mc@users.noreply.github.com>
2024-10-01 15:56:42 -04:00
Ed Minnix
26b49dd0df Fix test expectation 2024-10-01 15:56:40 -04:00
Ed Minnix
d80a1487be Add change note 2024-10-01 15:56:37 -04:00
Ed Minnix
e18389718c Implement stdin models
Unfortunately due to how variable and varargs work, these are better
done in QL
2024-10-01 15:56:31 -04:00
225 changed files with 3016 additions and 786 deletions

View File

@@ -1,3 +1,10 @@
## 2.0.2
### Minor Analysis Improvements
* Added taint flow model for `fopen` and related functions.
* The `SimpleRangeAnalysis` library (`semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis`) now generates more precise ranges for calls to `fgetc` and `getc`.
## 2.0.1
No user-facing changes.

View File

@@ -1,4 +0,0 @@
---
category: minorAnalysis
---
* The `SimpleRangeAnalysis` library (`semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis`) now generates more precise ranges for calls to `fgetc` and `getc`.

View File

@@ -1,4 +0,0 @@
---
category: minorAnalysis
---
* Added taint flow model for `fopen` and related functions.

View File

@@ -0,0 +1,6 @@
## 2.0.2
### Minor Analysis Improvements
* Added taint flow model for `fopen` and related functions.
* The `SimpleRangeAnalysis` library (`semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis`) now generates more precise ranges for calls to `fgetc` and `getc`.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 2.0.1
lastReleaseVersion: 2.0.2

View File

@@ -1,5 +1,5 @@
name: codeql/cpp-all
version: 2.0.2-dev
version: 2.0.2
groups: cpp
dbscheme: semmlecode.cpp.dbscheme
extractor: cpp

View File

@@ -1,3 +1,12 @@
## 1.2.5
### Minor Analysis Improvements
* The `cpp/unclear-array-index-validation` ("Unclear validation of array index") query has been improved to reduce false positives and increase true positives.
* Fixed false positives in the `cpp/uninitialized-local` ("Potentially uninitialized local variable") query if there are extraction errors in the function.
* The `cpp/incorrect-string-type-conversion` query now produces fewer false positives caused by failure to detect byte arrays.
* The `cpp/incorrect-string-type-conversion` query now produces fewer false positives caused by failure to recognize dynamic checks prior to possible dangerous widening.
## 1.2.4
### Minor Analysis Improvements

View File

@@ -1,5 +0,0 @@
---
category: minorAnalysis
---
* The `cpp/incorrect-string-type-conversion` query now produces fewer false positives caused by failure to detect byte arrays.
* The `cpp/incorrect-string-type-conversion` query now produces fewer false positives caused by failure to recognize dynamic checks prior to possible dangerous widening.

View File

@@ -1,4 +0,0 @@
---
category: minorAnalysis
---
* Fixed false positives in the `cpp/uninitialized-local` ("Potentially uninitialized local variable") query if there are extraction errors in the function.

View File

@@ -1,4 +0,0 @@
---
category: minorAnalysis
---
* The `cpp/unclear-array-index-validation` ("Unclear validation of array index") query has been improved to reduce false positives increase true positives.

View File

@@ -0,0 +1,8 @@
## 1.2.5
### Minor Analysis Improvements
* The `cpp/unclear-array-index-validation` ("Unclear validation of array index") query has been improved to reduce false positives and increase true positives.
* Fixed false positives in the `cpp/uninitialized-local` ("Potentially uninitialized local variable") query if there are extraction errors in the function.
* The `cpp/incorrect-string-type-conversion` query now produces fewer false positives caused by failure to detect byte arrays.
* The `cpp/incorrect-string-type-conversion` query now produces fewer false positives caused by failure to recognize dynamic checks prior to possible dangerous widening.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 1.2.4
lastReleaseVersion: 1.2.5

View File

@@ -1,5 +1,5 @@
name: codeql/cpp-queries
version: 1.2.5-dev
version: 1.2.5
groups:
- cpp
- queries

View File

@@ -1,74 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Semmle.Util;
namespace Semmle.Extraction.CSharp.DependencyFetching
{
public class NugetConfig
{
internal class NugetFeed : IComparable<NugetFeed>
{
internal string Value { get; }
internal bool DisableTlsCertificateValidation { get; set; }
internal NugetFeed(string value)
{
this.Value = value;
this.DisableTlsCertificateValidation = true;
}
public override string ToString()
{
return this.Value;
}
public int CompareTo(NugetFeed? other)
{
return this.Value.CompareTo(other?.Value);
}
}
internal IEnumerable<NugetFeed> Feeds { get; }
public NugetConfig()
{
this.Feeds = new List<NugetFeed>();
}
/// <summary>
/// Writes this configuration to a file located at <paramref name="nugetConfigPath"/>.
/// </summary>
/// <param name="nugetConfigPath">The path of the file to which the configuration should be written to.</param>
public void Write(string nugetConfigPath)
{
var config = "";
var proxyHost = Environment.GetEnvironmentVariable("CODEQL_PROXY_HOST");
var proxyPort = Environment.GetEnvironmentVariable("CODEQL_PROXY_PORT");
if (!string.IsNullOrWhiteSpace(proxyHost) && !string.IsNullOrWhiteSpace(proxyPort))
{
var proxyAddress = $"http://{proxyHost}:{proxyPort}";
config = $"""<add key="http_proxy" value="{proxyAddress}" />""";
}
var sb = new StringBuilder();
this.Feeds.ForEach((feed, index) => sb.AppendLine($"<add key=\"feed{index}\" value=\"{feed.Value}\" disableTLSCertificateValidation=\"{feed.DisableTlsCertificateValidation}\" />"));
File.WriteAllText(nugetConfigPath,
$"""
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
{config}
</config>
<packageSources>
<clear />
{sb}
</packageSources>
</configuration>
""");
}
}
}

View File

@@ -3,7 +3,6 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
@@ -94,25 +93,12 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
public HashSet<AssemblyLookupLocation> Restore()
{
try
{
var userConfigPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".nuget", "NuGet");
Directory.CreateDirectory(userConfigPath);
var userConfig = new NugetConfig();
userConfig.Write(Path.Join(userConfigPath, "NuGet.Config"));
}
catch (Exception ex)
{
logger.LogError($"Failed to write user nuget.config: {ex}");
}
var assemblyLookupLocations = new HashSet<AssemblyLookupLocation>();
var checkNugetFeedResponsiveness = EnvironmentVariables.GetBooleanOptOut(EnvironmentVariableNames.CheckNugetFeedResponsiveness);
logger.LogInfo($"Checking NuGet feed responsiveness: {checkNugetFeedResponsiveness}");
compilationInfoContainer.CompilationInfos.Add(("NuGet feed responsiveness checked", checkNugetFeedResponsiveness ? "1" : "0"));
HashSet<NugetConfig.NugetFeed>? explicitFeeds = null;
HashSet<string>? explicitFeeds = null;
try
{
@@ -189,12 +175,12 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
return assemblyLookupLocations;
}
private List<NugetConfig.NugetFeed> GetReachableFallbackNugetFeeds(HashSet<NugetConfig.NugetFeed>? feedsFromNugetConfigs)
private List<string> GetReachableFallbackNugetFeeds(HashSet<string>? feedsFromNugetConfigs)
{
var fallbackFeeds = EnvironmentVariables.GetURLs(EnvironmentVariableNames.FallbackNugetFeeds).Select(feed => new NugetConfig.NugetFeed(feed)).ToHashSet();
var fallbackFeeds = EnvironmentVariables.GetURLs(EnvironmentVariableNames.FallbackNugetFeeds).ToHashSet();
if (fallbackFeeds.Count == 0)
{
fallbackFeeds.Add(new NugetConfig.NugetFeed(PublicNugetOrgFeed));
fallbackFeeds.Add(PublicNugetOrgFeed);
logger.LogInfo($"No fallback Nuget feeds specified. Adding default feed: {PublicNugetOrgFeed}");
var shouldAddNugetConfigFeeds = EnvironmentVariables.GetBooleanOptOut(EnvironmentVariableNames.AddNugetConfigFeedsToFallback);
@@ -307,7 +293,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
compilationInfoContainer.CompilationInfos.Add(("Failed project restore with package source error", nugetSourceFailures.ToString()));
}
private AssemblyLookupLocation? DownloadMissingPackagesFromSpecificFeeds(HashSet<NugetConfig.NugetFeed>? feedsFromNugetConfigs)
private AssemblyLookupLocation? DownloadMissingPackagesFromSpecificFeeds(HashSet<string>? feedsFromNugetConfigs)
{
var reachableFallbackFeeds = GetReachableFallbackNugetFeeds(feedsFromNugetConfigs);
if (reachableFallbackFeeds.Count > 0)
@@ -319,7 +305,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
return null;
}
private AssemblyLookupLocation? DownloadMissingPackages(IEnumerable<NugetConfig.NugetFeed>? fallbackNugetFeeds = null)
private AssemblyLookupLocation? DownloadMissingPackages(IEnumerable<string>? fallbackNugetFeeds = null)
{
var alreadyDownloadedPackages = GetRestoredPackageDirectoryNames(PackageDirectory.DirInfo);
var alreadyDownloadedLegacyPackages = GetRestoredLegacyPackageNames();
@@ -381,14 +367,23 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
return missingPackageDirectory.DirInfo.FullName;
}
private string? CreateFallbackNugetConfig(IEnumerable<NugetConfig.NugetFeed> fallbackNugetFeeds, string folderPath)
private string? CreateFallbackNugetConfig(IEnumerable<string> fallbackNugetFeeds, string folderPath)
{
NugetConfig config = new NugetConfig();
fallbackNugetFeeds.ForEach((feed, index) => config.Feeds.Append(feed));
var sb = new StringBuilder();
fallbackNugetFeeds.ForEach((feed, index) => sb.AppendLine($"<add key=\"feed{index}\" value=\"{feed}\" />"));
var nugetConfigPath = Path.Combine(folderPath, "nuget.config");
logger.LogInfo($"Creating fallback nuget.config file {nugetConfigPath}.");
config.Write(nugetConfigPath);
File.WriteAllText(nugetConfigPath,
$"""
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
{sb}
</packageSources>
</configuration>
""");
return nugetConfigPath;
}
@@ -591,34 +586,10 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
}
}
private bool IsFeedReachable(NugetConfig.NugetFeed feed, int timeoutMilliSeconds, int tryCount, bool allowExceptions = true)
private bool IsFeedReachable(string feed, int timeoutMilliSeconds, int tryCount, bool allowExceptions = true)
{
logger.LogInfo($"Checking if Nuget feed '{feed}' is reachable...");
// Configure the handler for this check. If `DisableTlsCertificateValidation` is `true` for this feed,
// we disable certificate validation.
var handler = new HttpClientHandler();
var proxyHost = Environment.GetEnvironmentVariable("CODEQL_PROXY_HOST");
var proxyPort = Environment.GetEnvironmentVariable("CODEQL_PROXY_PORT");
if (!string.IsNullOrWhiteSpace(proxyHost) && !string.IsNullOrWhiteSpace(proxyPort))
{
var proxyAddress = new Uri($"http://{proxyHost}:{proxyPort}");
handler.Proxy = new WebProxy(proxyAddress);
handler.Proxy.Credentials = new NetworkCredential(Environment.GetEnvironmentVariable("CODEQL_PROXY_USER"), Environment.GetEnvironmentVariable("CODEQL_PROXY_PASSWORD"));
logger.LogInfo($"Using proxy at {proxyAddress}...");
}
if (feed.DisableTlsCertificateValidation)
{
logger.LogInfo($"Disabling TLS certificate validation for '{feed}'...");
handler.ClientCertificateOptions = ClientCertificateOption.Manual;
handler.ServerCertificateCustomValidationCallback =
(httpRequestMessage, cert, certChain, policyErrors) => { return true; };
}
using HttpClient client = new(handler);
using HttpClient client = new();
for (var i = 0; i < tryCount; i++)
{
@@ -626,7 +597,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
cts.CancelAfter(timeoutMilliSeconds);
try
{
ExecuteGetRequest(feed.Value, client, cts.Token).GetAwaiter().GetResult();
ExecuteGetRequest(feed, client, cts.Token).GetAwaiter().GetResult();
logger.LogInfo($"Querying Nuget feed '{feed}' succeeded.");
return true;
}
@@ -644,13 +615,6 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
// We're only interested in timeouts.
var start = allowExceptions ? "Considering" : "Not considering";
logger.LogInfo($"Querying Nuget feed '{feed}' failed in a timely manner. {start} the feed for use. The reason for the failure: {exc.Message}");
logger.LogError($"Exception: {exc}");
if (exc.InnerException != null)
{
logger.LogError($"Inner exception: {exc.InnerException}");
}
return allowExceptions;
}
}
@@ -678,7 +642,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
return (timeoutMilliSeconds, tryCount);
}
private bool CheckFeeds(out HashSet<NugetConfig.NugetFeed> explicitFeeds)
private bool CheckFeeds(out HashSet<string> explicitFeeds)
{
logger.LogInfo("Checking Nuget feeds...");
(explicitFeeds, var allFeeds) = GetAllFeeds();
@@ -693,7 +657,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
var (initialTimeout, tryCount) = GetFeedRequestSettings(isFallback: false);
var allFeedsReachable = explicitFeeds.All(feed => excludedFeeds.Contains(feed.Value) || IsFeedReachable(feed, initialTimeout, tryCount));
var allFeedsReachable = explicitFeeds.All(feed => excludedFeeds.Contains(feed) || IsFeedReachable(feed, initialTimeout, tryCount));
if (!allFeedsReachable)
{
logger.LogWarning("Found unreachable Nuget feed in C# analysis with build-mode 'none'. This may cause missing dependencies in the analysis.");
@@ -747,12 +711,11 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
}
}
private (HashSet<NugetConfig.NugetFeed> explicitFeeds, HashSet<NugetConfig.NugetFeed> allFeeds) GetAllFeeds()
private (HashSet<string> explicitFeeds, HashSet<string> allFeeds) GetAllFeeds()
{
var nugetConfigs = fileProvider.NugetConfigs;
var explicitFeeds = nugetConfigs
.SelectMany(config => GetFeeds(() => dotnet.GetNugetFeeds(config)))
.Select(feed => new NugetConfig.NugetFeed(feed))
.ToHashSet();
if (explicitFeeds.Count > 0)
@@ -781,7 +744,6 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
})
.Where(folder => folder != null)
.SelectMany(folder => GetFeeds(() => dotnet.GetNugetFeedsFromFolder(folder!)))
.Select(feed => new NugetConfig.NugetFeed(feed))
.ToHashSet();
logger.LogInfo($"Found {allFeeds.Count} Nuget feeds (with inherited ones) in nuget.config files: {string.Join(", ", allFeeds.OrderBy(f => f))}");

View File

@@ -1,3 +1,7 @@
## 1.7.27
No user-facing changes.
## 1.7.26
No user-facing changes.

View File

@@ -0,0 +1,3 @@
## 1.7.27
No user-facing changes.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 1.7.26
lastReleaseVersion: 1.7.27

View File

@@ -1,5 +1,5 @@
name: codeql/csharp-solorigate-all
version: 1.7.27-dev
version: 1.7.27
groups:
- csharp
- solorigate

View File

@@ -1,3 +1,7 @@
## 1.7.27
No user-facing changes.
## 1.7.26
No user-facing changes.

View File

@@ -0,0 +1,3 @@
## 1.7.27
No user-facing changes.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 1.7.26
lastReleaseVersion: 1.7.27

View File

@@ -1,5 +1,5 @@
name: codeql/csharp-solorigate-queries
version: 1.7.27-dev
version: 1.7.27
groups:
- csharp
- solorigate

View File

@@ -1,3 +1,7 @@
## 3.0.1
No user-facing changes.
## 3.0.0
### Breaking Changes

View File

@@ -0,0 +1,3 @@
## 3.0.1
No user-facing changes.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 3.0.0
lastReleaseVersion: 3.0.1

View File

@@ -1,5 +1,5 @@
name: codeql/csharp-all
version: 3.0.1-dev
version: 3.0.1
groups: csharp
dbscheme: semmlecode.csharp.dbscheme
extractor: csharp

View File

@@ -1,3 +1,7 @@
## 1.0.10
No user-facing changes.
## 1.0.9
### Minor Analysis Improvements

View File

@@ -0,0 +1,3 @@
## 1.0.10
No user-facing changes.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 1.0.9
lastReleaseVersion: 1.0.10

View File

@@ -1,5 +1,5 @@
name: codeql/csharp-queries
version: 1.0.10-dev
version: 1.0.10
groups:
- csharp
- queries

View File

@@ -101,7 +101,7 @@
latest version of CodeQL...</div>
</div>
<div class="Subhead border-0">
<a href="query-help/codeql-cwe-coverage/">
<a href="../codeql-query-help/codeql-cwe-coverage/">
<div class="Subhead-heading f4 text-center">CodeQL coverage of CWEs</div>
</a>
<div class="Subhead-description">Detailed information on the coverage of Common Weakness Enumerations (CWEs) in the latest release...</div>

View File

@@ -1,3 +1,7 @@
## 1.0.10
No user-facing changes.
## 1.0.9
No user-facing changes.

View File

@@ -0,0 +1,3 @@
## 1.0.10
No user-facing changes.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 1.0.9
lastReleaseVersion: 1.0.10

View File

@@ -1,5 +1,5 @@
name: codeql-go-consistency-queries
version: 1.0.10-dev
version: 1.0.10
groups:
- go
- queries

View File

@@ -1,3 +1,11 @@
## 2.1.1
### Minor Analysis Improvements
* Added member predicates `StructTag.hasOwnFieldWithTag` and `Field.getTag`, which enable CodeQL queries to examine struct field tags.
* Added member predicate `InterfaceType.hasPrivateMethodWithQualifiedName`, which enables CodeQL queries to distinguish interfaces with matching non-exported method names that are declared in different packages, and are therefore incompatible.
* Local source models with the `stdin` source kind have been added for the variable `os.Stdin` and the functions `fmt.Scan`, `fmt.Scanf` and `fmt.Scanln`. You can optionally include threat models as appropriate when using the CodeQL CLI and in GitHub code scanning. For more information, see [Analyzing your code with CodeQL queries](https://docs.github.com/code-security/codeql-cli/getting-started-with-the-codeql-cli/analyzing-your-code-with-codeql-queries#including-model-packs-to-add-potential-sources-of-tainted-data>) and [Customizing your advanced setup for code scanning](https://docs.github.com/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#extending-codeql-coverage-with-threat-models).
## 2.1.0
### Deprecated APIs

View File

@@ -1,5 +0,0 @@
---
category: minorAnalysis
---
* Added member predicates `StructTag.hasOwnFieldWithTag` and `Field.getTag`, which enable CodeQL queries to examine struct field tags.
* Added member predicate `InterfaceType.hasPrivateMethodWithQualifiedName`, which enables CodeQL queries to distinguish interfaces with matching non-exported method names that are declared in different packages, and are therefore incompatible.

View File

@@ -0,0 +1,7 @@
## 2.1.1
### Minor Analysis Improvements
* Added member predicates `StructTag.hasOwnFieldWithTag` and `Field.getTag`, which enable CodeQL queries to examine struct field tags.
* Added member predicate `InterfaceType.hasPrivateMethodWithQualifiedName`, which enables CodeQL queries to distinguish interfaces with matching non-exported method names that are declared in different packages, and are therefore incompatible.
* Local source models with the `stdin` source kind have been added for the variable `os.Stdin` and the functions `fmt.Scan`, `fmt.Scanf` and `fmt.Scanln`. You can optionally include threat models as appropriate when using the CodeQL CLI and in GitHub code scanning. For more information, see [Analyzing your code with CodeQL queries](https://docs.github.com/code-security/codeql-cli/getting-started-with-the-codeql-cli/analyzing-your-code-with-codeql-queries#including-model-packs-to-add-potential-sources-of-tainted-data>) and [Customizing your advanced setup for code scanning](https://docs.github.com/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#extending-codeql-coverage-with-threat-models).

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 2.1.0
lastReleaseVersion: 2.1.1

View File

@@ -1,5 +1,5 @@
name: codeql/go-all
version: 2.1.1-dev
version: 2.1.1
groups: go
dbscheme: go.dbscheme
extractor: go

View File

@@ -727,7 +727,10 @@ module Public {
override string getNodeKind() { result = "external parameter node" }
override Type getType() {
result = this.getSummarizedCallable().getType().getParameterType(this.getPos())
result =
this.getSummarizedCallable()
.getType()
.getParameterType(pragma[only_bind_into](this.getPos()))
or
this.getPos() = -1 and
result = this.getSummarizedCallable().asFunction().(Method).getReceiverType()

View File

@@ -112,6 +112,15 @@ module Fmt {
Scanner() { this.hasQualifiedName("fmt", ["Scan", "Scanf", "Scanln"]) }
}
private class ScannerSource extends SourceNode {
ScannerSource() {
// All of the arguments which are sources are varargs.
this.asExpr() = any(Scanner s).getACall().getAnImplicitVarargsArgument().asExpr()
}
override string getThreatModel() { result = "stdin" }
}
/**
* The `Fscan` function or one of its variants,
* all of which read from a specified `io.Reader`.

View File

@@ -43,4 +43,12 @@ module Os {
input = inp and output = outp
}
}
private class Stdin extends SourceNode {
Stdin() {
exists(Variable osStdin | osStdin.hasQualifiedName("os", "Stdin") | this = osStdin.getARead())
}
override string getThreatModel() { result = "stdin" }
}
}

View File

@@ -1,3 +1,7 @@
## 1.1.1
No user-facing changes.
## 1.1.0
### Query Metadata Changes

View File

@@ -0,0 +1,3 @@
## 1.1.1
No user-facing changes.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 1.1.0
lastReleaseVersion: 1.1.1

View File

@@ -1,5 +1,5 @@
name: codeql/go-queries
version: 1.1.1-dev
version: 1.1.1
groups:
- go
- queries

View File

@@ -0,0 +1,3 @@
module test
go 1.22.6

View File

@@ -0,0 +1,3 @@
testFailures
invalidModelRow
failures

View File

@@ -0,0 +1,7 @@
extensions:
- addsTo:
pack: codeql/threat-models
extensible: threatModelConfiguration
data:
- ["stdin", true, 0]

View File

@@ -0,0 +1,19 @@
import go
import ModelValidation
import TestUtilities.InlineExpectationsTest
module SourceTest implements TestSig {
string getARelevantTag() { result = "source" }
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(ActiveThreatModelSource s |
s.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
element = s.toString() and
value = "" and
tag = "source"
)
}
}
import MakeTest<SourceTest>

View File

@@ -0,0 +1,2 @@
testFailures
invalidModelRow

View File

@@ -0,0 +1,7 @@
extensions:
- addsTo:
pack: codeql/threat-models
extensible: threatModelConfiguration
data:
- ["stdin", true, 0]

View File

@@ -0,0 +1,48 @@
package test
import (
"bufio"
"fmt"
"os"
)
func sink(string) {
}
func readStdinBuffer() {
buf := make([]byte, 1024)
n, err := os.Stdin.Read(buf) // $source
if err != nil {
return
}
sink(string(buf[:n])) // $hasTaintFlow="type conversion"
}
func readStdinBuffReader() {
buf := make([]byte, 1024)
r := bufio.NewReader(os.Stdin) // $source
n, err := r.Read(buf)
if err != nil {
return
}
sink(string(buf[:n])) // $hasTaintFlow="type conversion"
}
func scan() {
var username, email string
fmt.Scan(&username, &email) // $source
sink(username) // $hasTaintFlow="username"
}
func scanf() {
var s string
fmt.Scanf("%s", &s) // $source
sink(s) // $hasTaintFlow="s"
}
func scanl() {
var s string
fmt.Scanln(&s) // $source
sink(s) // $hasTaintFlow="s"
}

View File

@@ -0,0 +1,15 @@
import go
import semmle.go.dataflow.ExternalFlow
import ModelValidation
import experimental.frameworks.CleverGo
import TestUtilities.InlineFlowTest
module Config implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { source instanceof ActiveThreatModelSource }
predicate isSink(DataFlow::Node sink) {
sink.asExpr() = any(CallExpr c | c.getTarget().getName() = "sink").getArgument(0)
}
}
import TaintFlowTest<Config>

View File

@@ -1,3 +1,7 @@
## 1.0.10
No user-facing changes.
## 1.0.9
No user-facing changes.

View File

@@ -0,0 +1,3 @@
## 1.0.10
No user-facing changes.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 1.0.9
lastReleaseVersion: 1.0.10

View File

@@ -1,5 +1,5 @@
name: codeql/java-automodel-queries
version: 1.0.10-dev
version: 1.0.10
groups:
- java
- automodel

View File

@@ -1,3 +1,7 @@
## 4.1.1
No user-facing changes.
## 4.1.0
### Deprecated APIs

View File

@@ -0,0 +1,3 @@
## 4.1.1
No user-facing changes.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 4.1.0
lastReleaseVersion: 4.1.1

View File

@@ -1,5 +1,5 @@
name: codeql/java-all
version: 4.1.1-dev
version: 4.1.1
groups: java
dbscheme: config/semmlecode.dbscheme
extractor: java

View File

@@ -1,3 +1,7 @@
## 1.1.7
No user-facing changes.
## 1.1.6
### Minor Analysis Improvements

View File

@@ -0,0 +1,3 @@
## 1.1.7
No user-facing changes.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 1.1.6
lastReleaseVersion: 1.1.7

View File

@@ -1,5 +1,5 @@
name: codeql/java-queries
version: 1.1.7-dev
version: 1.1.7
groups:
- java
- queries

View File

@@ -1,3 +1,7 @@
## 2.0.2
No user-facing changes.
## 2.0.1
No user-facing changes.

View File

@@ -0,0 +1,3 @@
## 2.0.2
No user-facing changes.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 2.0.1
lastReleaseVersion: 2.0.2

View File

@@ -1,5 +1,5 @@
name: codeql/javascript-all
version: 2.0.2-dev
version: 2.0.2
groups: javascript
dbscheme: semmlecode.javascript.dbscheme
extractor: javascript

View File

@@ -1,3 +1,7 @@
## 1.2.2
No user-facing changes.
## 1.2.1
No user-facing changes.

View File

@@ -0,0 +1,3 @@
## 1.2.2
No user-facing changes.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 1.2.1
lastReleaseVersion: 1.2.2

View File

@@ -1,5 +1,5 @@
name: codeql/javascript-queries
version: 1.2.2-dev
version: 1.2.2
groups:
- javascript
- queries

View File

@@ -1,3 +1,7 @@
## 1.0.10
No user-facing changes.
## 1.0.9
No user-facing changes.

View File

@@ -0,0 +1,3 @@
## 1.0.10
No user-facing changes.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 1.0.9
lastReleaseVersion: 1.0.10

View File

@@ -1,4 +1,4 @@
name: codeql/suite-helpers
version: 1.0.10-dev
version: 1.0.10
groups: shared
warnOnImplicitThis: true

View File

@@ -13,10 +13,10 @@ rm -rf dbs
mkdir dbs
CODEQL_EXTRACTOR_PYTHON_DONT_EXTRACT_STDLIB=True $CODEQL database create dbs/without-stdlib --language python --source-root repo_dir/
$CODEQL database create dbs/without-stdlib --language python --source-root repo_dir/
$CODEQL query run --database dbs/without-stdlib query.ql > query.without-stdlib.actual
diff query.without-stdlib.expected query.without-stdlib.actual
LGTM_INDEX_EXCLUDE="/usr/lib/**" $CODEQL database create dbs/with-stdlib --language python --source-root repo_dir/
LGTM_INDEX_EXCLUDE="/usr/lib/**" CODEQL_EXTRACTOR_PYTHON_EXTRACT_STDLIB=True $CODEQL database create dbs/with-stdlib --language python --source-root repo_dir/
$CODEQL query run --database dbs/with-stdlib query.ql > query.with-stdlib.actual
diff query.with-stdlib.expected query.with-stdlib.actual

View File

@@ -1,5 +0,0 @@
| name |
+----------+
| dircache |
| stat |
| test |

View File

@@ -1,5 +1,3 @@
| name |
+----------+
| dircache |
| stat |
| test |
| name |
+------+
| test |

View File

@@ -1,4 +1,3 @@
| name |
+------+
| stat |
| test |

View File

@@ -102,8 +102,10 @@ def make_parser():
config_options.add_option("--colorize", dest="colorize", default=False, action="store_true",
help = """Colorize the logging output.""")
config_options.add_option("--dont-extract-stdlib", dest="extract_stdlib", default=True, action="store_false",
help="Do not extract the standard library.")
config_options.add_option("--dont-extract-stdlib", dest="extract_stdlib", action="store_false",
help="This flag is deprecated; not extracting the standard library is now the default.")
config_options.add_option("--extract-stdlib", dest="extract_stdlib", default=False, action="store_true",
help="Extract the standard library.")
parser.add_option_group(config_options)
@@ -226,8 +228,18 @@ def parse(command_line):
if 'CODEQL_EXTRACTOR_PYTHON_DONT_EXTRACT_STDLIB' in os.environ:
options.extract_stdlib = False
print ("WARNING: CODEQL_EXTRACTOR_PYTHON_DONT_EXTRACT_STDLIB is deprecated; the default is now to not extract the standard library.")
if 'CODEQL_EXTRACTOR_PYTHON_EXTRACT_STDLIB' in os.environ:
options.extract_stdlib = True
options.prune = True
if options.extract_stdlib:
print ("WARNING: The analysis will extract the standard library. This behavior is deprecated and will be removed in a future release. We expect it to be gone in CLI version 2.20.0.")
else:
print ("INFO: The Python extractor has recently stopped extracting the standard library by default. If you encounter problems, please let us know by submitting an issue to https://github.com/github/codeql. It is possible to re-enable extraction of the standard library by setting the environment variable CODEQL_EXTRACTOR_PYTHON_EXTRACT_STDLIB.")
return options, args
def split_and_flatten(options_list, div):

View File

@@ -67,7 +67,7 @@ def main(sys_path = sys.path[:]):
update_analysis_version(last_version)
found_py2 = False
if get_analysis_major_version() == 2:
if get_analysis_major_version() == 2 and options.extract_stdlib:
# Setup `sys_path` to use the Python 2 standard library
sys_path, found_py2 = get_py2_sys_path(logger, sys_path)

View File

@@ -10,7 +10,7 @@ from io import BytesIO
#Semantic version of extractor.
#Update this if any changes are made
VERSION = "6.1.2"
VERSION = "7.0.0"
PY_EXTENSIONS = ".py", ".pyw"

View File

@@ -1,3 +1,13 @@
## 2.1.1
### Minor Analysis Improvements
* Modelled that `re.finditer` returns an iterable of `re.Match` objects. This is now understood by the API graph in many cases.
* Type tracking, and hence the API graph, is now able to correctly trace through comprehensions.
* More precise modelling of the dataflow through comprehensions. In particular, captured variables are now handled correctly.
* Dataflow out of yield is added, allowing proper tracing through generators.
* Added several models of standard library functions and classes, in anticipation of no longer extracting the standard library in a future release.
## 2.1.0
### New Features

View File

@@ -1,4 +0,0 @@
---
category: minorAnalysis
---
* Added several models of standard library functions and classes, in anticipation of no longer extracting the standard library in a future release.

View File

@@ -1,5 +0,0 @@
---
category: minorAnalysis
---
* More precise modelling of the dataflow through comprehensions. In particular, captured variables are now handled correctly.
* Dataflow out of yield is added, allowing proper tracing through generators.

View File

@@ -1,4 +0,0 @@
---
category: minorAnalysis
---
* Type tracking, and hence the API graph, is now able to correctly trace trough comprehensions.

View File

@@ -1,4 +0,0 @@
---
category: minorAnalysis
---
* Modelled that `re.finditer` returns an iterable of `re.Match` objects. This is now understood by the API graph in many cases.

View File

@@ -0,0 +1,9 @@
## 2.1.1
### Minor Analysis Improvements
* Modelled that `re.finditer` returns an iterable of `re.Match` objects. This is now understood by the API graph in many cases.
* Type tracking, and hence the API graph, is now able to correctly trace through comprehensions.
* More precise modelling of the dataflow through comprehensions. In particular, captured variables are now handled correctly.
* Dataflow out of yield is added, allowing proper tracing through generators.
* Added several models of standard library functions and classes, in anticipation of no longer extracting the standard library in a future release.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 2.1.0
lastReleaseVersion: 2.1.1

View File

@@ -1,5 +1,5 @@
name: codeql/python-all
version: 2.1.1-dev
version: 2.1.1
groups: python
dbscheme: semmlecode.python.dbscheme
extractor: python

View File

@@ -65,6 +65,10 @@ extensions:
- ["getopt", "Member[getopt]", "Argument[1,shortopts:,2,longopts:]", "ReturnValue.TupleElement[0].ListElement.TupleElement[0]", "taint"]
# See https://docs.python.org/3/library/gettext.html#gettext.gettext
- ["gettext", "Member[gettext]", "Argument[0,message:]", "ReturnValue", "taint"]
# See
# - https://docs.python.org/3/library/glob.html#glob.glob
# - https://docs.python.org/3/library/glob.html#glob.iglob
- ["glob", "Member[glob,iglob]", "Argument[0,pathname:]", "ReturnValue", "taint"]
# See https://docs.python.org/3/library/gzip.html#gzip.GzipFile
- ["gzip.GzipFile!", "Subclass.Call", "Argument[0,filename:]", "ReturnValue", "taint"]
# See
@@ -88,6 +92,8 @@ extensions:
- ["nturl2path", "Member[url2pathname]", "Argument[0,url:]", "ReturnValue", "taint"]
# See https://docs.python.org/3/library/optparse.html#optparse.OptionParser.parse_args
- ["optparse.OptionParser", "Member[parse_args]", "Argument[0,args:,1,values:]", "ReturnValue.TupleElement[0,1]", "taint"]
# See https://docs.python.org/3/library/os.html#os.walk
- ["os", "Member[walk]", "Argument[0,top:]", "ReturnValue", "taint"]
# See https://github.com/python/cpython/blob/3.10/Lib/pathlib.py#L972-L973
- ["pathlib.Path", ".Member[__enter__]", "Argument[self]", "ReturnValue", "taint"]
# See https://docs.python.org/3/library/os.html#os.PathLike.__fspath__

View File

@@ -1,8 +1,12 @@
## 1.3.1
No user-facing changes.
## 1.3.0
### New Queries
* The `py/cors-misconfiguration-with-credentials` query, which finds insecure CORS middleware configurations.
* The experimental `py/cors-misconfiguration-with-credentials` query, which finds insecure CORS middleware configurations.
## 1.2.2

View File

@@ -0,0 +1,3 @@
## 1.3.1
No user-facing changes.

View File

@@ -1,2 +1,2 @@
---
lastReleaseVersion: 1.3.0
lastReleaseVersion: 1.3.1

View File

@@ -1,5 +1,5 @@
name: codeql/python-queries
version: 1.3.1-dev
version: 1.3.1
groups:
- python
- queries

Some files were not shown because too many files have changed in this diff Show More