mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
C#: Extract attributes of referenced assembly
This commit is contained in:
@@ -198,12 +198,12 @@ namespace Semmle.Extraction.CSharp
|
||||
/// Perform an analysis on an assembly.
|
||||
/// </summary>
|
||||
/// <param name="assembly">Assembly to analyse.</param>
|
||||
private void AnalyseAssembly(PortableExecutableReference assembly)
|
||||
private void AnalyseReferenceAssembly(PortableExecutableReference assembly)
|
||||
{
|
||||
// CIL first - it takes longer.
|
||||
if (options.CIL)
|
||||
extractionTasks.Add(() => DoExtractCIL(assembly));
|
||||
extractionTasks.Add(() => DoAnalyseAssembly(assembly));
|
||||
extractionTasks.Add(() => DoAnalyseReferenceAssembly(assembly));
|
||||
}
|
||||
|
||||
private static bool FileIsUpToDate(string src, string dest)
|
||||
@@ -250,7 +250,7 @@ namespace Semmle.Extraction.CSharp
|
||||
/// extraction within the snapshot.
|
||||
/// </summary>
|
||||
/// <param name="r">The assembly to extract.</param>
|
||||
private void DoAnalyseAssembly(PortableExecutableReference r)
|
||||
private void DoAnalyseReferenceAssembly(PortableExecutableReference r)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -294,6 +294,8 @@ namespace Semmle.Extraction.CSharp
|
||||
AnalyseNamespace(cx, module.GlobalNamespace);
|
||||
}
|
||||
|
||||
Entities.Attribute.ExtractAttributes(cx, assembly, Extraction.Entities.Assembly.Create(cx, assembly.GetSymbolLocation()));
|
||||
|
||||
cx.PopulateAll();
|
||||
}
|
||||
}
|
||||
@@ -335,7 +337,7 @@ namespace Semmle.Extraction.CSharp
|
||||
{
|
||||
foreach (var r in compilation.References.OfType<PortableExecutableReference>())
|
||||
{
|
||||
AnalyseAssembly(r);
|
||||
AnalyseReferenceAssembly(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,5 +3,5 @@ import csharp
|
||||
from Attributable element, Attribute attribute
|
||||
where
|
||||
attribute = element.getAnAttribute() and
|
||||
(element.(Element).fromSource() or element instanceof Assembly)
|
||||
(element.(Element).fromSource() or element.(Assembly).getName() = "attributes")
|
||||
select element, attribute, attribute.getType().getQualifiedName()
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
arguments
|
||||
| Assembly1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null | 0 | 1 |
|
||||
| Assembly1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null | 1 | array creation of type Object[] |
|
||||
| Assembly1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null | 2 | typeof(...) |
|
||||
| Assembly1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null | 3 | (...) ... |
|
||||
| Assembly1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null | 4 | null |
|
||||
| Assembly1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null | 5 | array creation of type Object[] |
|
||||
| Class1 | 0 | 3 |
|
||||
| Class1 | 1 | array creation of type Int32[] |
|
||||
| Class1 | 2 | null |
|
||||
@@ -12,6 +18,7 @@ arguments
|
||||
| Method1 | 4 | array creation of type Int32[] |
|
||||
| Method1 | 5 | array creation of type Object[] |
|
||||
literals
|
||||
| 1 | Int32 | 1 |
|
||||
| 3 | Int32 | 3 |
|
||||
| 42 | Int32 | 42 |
|
||||
| null | null | null |
|
||||
@@ -20,9 +27,13 @@ enums
|
||||
| (...) ... | 43 | access to type Enum1 | 43 |
|
||||
typeof
|
||||
| typeof(...) | access to type Class1 |
|
||||
| typeof(...) | access to type CustomAttribute |
|
||||
array
|
||||
| array creation of type Int32[] | 3 | 0 | 1 |
|
||||
| array creation of type Int32[] | 3 | 1 | 2 |
|
||||
| array creation of type Int32[] | 3 | 2 | 3 |
|
||||
| array creation of type Object[] | 2 | 0 | 1 |
|
||||
| array creation of type Object[] | 2 | 1 | typeof(...) |
|
||||
| array creation of type Object[] | 3 | 0 | 1 |
|
||||
| array creation of type Object[] | 3 | 1 | 2 |
|
||||
| array creation of type Object[] | 3 | 2 | null |
|
||||
|
||||
Reference in New Issue
Block a user