Skip to content

Commit 4024e83

Browse files
Merge branch 'github:main' into main-1
2 parents 997ab2c + e73745d commit 4024e83

File tree

25 files changed

+217
-31
lines changed

25 files changed

+217
-31
lines changed

.vscode/tasks.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
"${input:name}",
5151
"${input:categoryQuery}"
5252
],
53+
"options": {
54+
"env": {
55+
"EDITOR": "code -r",
56+
}
57+
},
5358
"presentation": {
5459
"reveal": "never",
5560
"close": true
@@ -67,6 +72,11 @@
6772
"${input:name}",
6873
"${input:categoryLibrary}"
6974
],
75+
"options": {
76+
"env": {
77+
"EDITOR": "code -r"
78+
}
79+
},
7080
"presentation": {
7181
"reveal": "never",
7282
"close": true

actions/ql/src/change-notes/2025-02-27-immutable-actions-list.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
category: fix
33
---
44
* The `actions/unversioned-immutable-action` query will no longer report any alerts, since the
5-
Immutable Actions feature is not yet available for customer use. The query remains in the
6-
default Code Scanning suites for use internal to GitHub. Once the Immutable Actions feature is
7-
available, the query will be updated to report alerts again.
5+
Immutable Actions feature is not yet available for customer use. The query has also been moved
6+
to the experimental folder and will not be used in code scanning unless it is explicitly added
7+
to a code scanning configuration. Once the Immutable Actions feature is available, the query will
8+
be updated to report alerts again.

actions/ql/src/Security/CWE-829/UnversionedImmutableAction.ql renamed to actions/ql/src/experimental/Security/CWE-829/UnversionedImmutableAction.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @tags security
99
* actions
1010
* internal
11+
* experimental
1112
* external/cwe/cwe-829
1213
*/
1314

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Security/CWE-829/UnversionedImmutableAction.ql
1+
experimental/Security/CWE-829/UnversionedImmutableAction.ql

cpp/ql/src/Metrics/Internal/IncludeResolutionStatus.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @name Include file resolution status
3-
* @description A count of successful includes and includes that failed to resolve.
4-
* This query is for internal use only and may change without notice.
3+
* @description Counts unresolved and resolved #includes.
4+
* This query is for internal use only and may change without notice.
55
* @kind table
66
* @id cpp/include-resolution-status
77
*/

csharp/extractor/Semmle.Extraction.CSharp/Entities/Assembly.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public override void Populate(TextWriter trapFile)
3131
{
3232
if (assemblyPath is not null)
3333
{
34-
var isBuildlessOutputAssembly = isOutputAssembly && Context.ExtractionContext.Mode.HasFlag(ExtractorMode.Standalone);
34+
var isBuildlessOutputAssembly = isOutputAssembly && Context.ExtractionContext.IsStandalone;
3535
var identifier = isBuildlessOutputAssembly
3636
? ""
3737
: assembly.ToString() ?? "";
@@ -72,7 +72,7 @@ public static Assembly CreateOutputAssembly(Context cx)
7272

7373
public override void WriteId(EscapingTextWriter trapFile)
7474
{
75-
if (isOutputAssembly && Context.ExtractionContext.Mode.HasFlag(ExtractorMode.Standalone))
75+
if (isOutputAssembly && Context.ExtractionContext.IsStandalone)
7676
{
7777
trapFile.Write("buildlessOutputAssembly");
7878
}

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/Invocation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public IMethodSymbol? TargetSymbol
133133
.Where(method => method.Parameters.Length >= Syntax.ArgumentList.Arguments.Count)
134134
.Where(method => method.Parameters.Count(p => !p.HasExplicitDefaultValue) <= Syntax.ArgumentList.Arguments.Count);
135135

136-
return Context.ExtractionContext.Mode.HasFlag(ExtractorMode.Standalone) ?
136+
return Context.ExtractionContext.IsStandalone ?
137137
candidates.FirstOrDefault() :
138138
candidates.SingleOrDefault();
139139
}

csharp/extractor/Semmle.Extraction.CSharp/Entities/Types/NamedType.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ private class UnderlyingTupleTypeFactory : CachedEntityFactory<INamedTypeSymbol,
166166
// Create typerefs for constructed error types in case they are fully defined elsewhere.
167167
// We cannot use `!this.NeedsPopulation` because this would not be stable as it would depend on
168168
// the assembly that was being extracted at the time.
169-
private bool UsesTypeRef => Symbol.TypeKind == TypeKind.Error || SymbolEqualityComparer.Default.Equals(Symbol.OriginalDefinition, Symbol);
169+
private bool UsesTypeRef =>
170+
Symbol.TypeKind == TypeKind.Error ||
171+
SymbolEqualityComparer.Default.Equals(Symbol.OriginalDefinition, Symbol);
170172

171173
public override Type TypeRef => UsesTypeRef ? (Type)NamedTypeRef.Create(Context, Symbol) : this;
172174
}

csharp/extractor/Semmle.Extraction.CSharp/Entities/Types/Type.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,40 @@ public static bool ConstructedOrParentIsConstructed(INamedTypeSymbol symbol)
2525
symbol.ContainingType is not null && ConstructedOrParentIsConstructed(symbol.ContainingType);
2626
}
2727

28+
29+
/// <summary>
30+
/// A hashset containing the C# contextual keywords that could be confused with types (and typing).
31+
///
32+
/// For the list of all contextual keywords, see
33+
/// https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/#contextual-keywords
34+
/// </summary>
35+
private readonly HashSet<string> ContextualKeywordTypes = [
36+
"dynamic",
37+
"nint",
38+
"nuint",
39+
"var"
40+
];
41+
42+
/// <summary>
43+
/// Returns true in case we suspect this is a broken type.
44+
/// </summary>
45+
/// <param name="symbol">Type symbol</param>
46+
private bool IsBrokenType(ITypeSymbol symbol)
47+
{
48+
if (!Context.ExtractionContext.IsStandalone ||
49+
!symbol.FromSource() ||
50+
symbol.IsAnonymousType)
51+
{
52+
return false;
53+
}
54+
55+
// (1) public class { ... } is a broken type as it doesn't have a name.
56+
// (2) public class var { ... } is an allowed type, but it overrides the `var` keyword for all uses.
57+
// The same goes for other contextual keywords that could be used as type names.
58+
// It is probably a better heuristic to treat these as broken types.
59+
return string.IsNullOrEmpty(symbol.Name) || ContextualKeywordTypes.Contains(symbol.Name);
60+
}
61+
2862
public Kinds.TypeKind GetTypeKind(Context cx, bool constructUnderlyingTupleType)
2963
{
3064
switch (Symbol.SpecialType)
@@ -48,6 +82,9 @@ public Kinds.TypeKind GetTypeKind(Context cx, bool constructUnderlyingTupleType)
4882
if (Symbol.IsBoundNullable())
4983
return Kinds.TypeKind.NULLABLE;
5084

85+
if (IsBrokenType(Symbol))
86+
return Kinds.TypeKind.UNKNOWN;
87+
5188
switch (Symbol.TypeKind)
5289
{
5390
case TypeKind.Class: return Kinds.TypeKind.CLASS;

0 commit comments

Comments
 (0)