Skip to content

Commit 4a55d8d

Browse files
CornielLauraXiulan
andauthored
Documentation for Proj0503 and Proj0504 (#102)
Co-authored-by: Laura Kramer <laurakramer91@gmail.com>
1 parent 26668c3 commit 4a55d8d

File tree

3 files changed

+108
-0
lines changed

3 files changed

+108
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ reported a the [GibHub repository](https://github.com/dotnet-project-file-analyz
136136
* [**Proj0500** Only include packages with an explicitly defined license](rules/Proj0500.md)
137137
* [**Proj0501** Package only contains a deprecated license URL](rules/Proj0501.md)
138138
* [**Proj0502** Only include packages compliant with project license](rules/Proj0502.md)
139+
* [**Proj0503** Package license is unknown](rules/Proj0503.md)
140+
* [**Proj0504** Package license has changed](rules/Proj0504.md)
139141

140142
### .NET Project File Analyzers SDK
141143
* [**Proj0700** Avoid defining &lt;Compile&gt; items in SDK project](rules/Proj0700.md)

rules/Proj0503.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
parent: Licensing
3+
ancestor: Rules
4+
---
5+
6+
# Proj0503: Package license is unknown
7+
Using a [NuGet](https://www.nuget.org) package implies that you
8+
and/or your company explicitly agree with the legally binding conditions of the
9+
license and the copyright of the owner of the package.
10+
11+
If a third-party package license comes with a custom license (other than one
12+
specified by the [SPDX](https://spdx.dev)), this rule ensures that the license
13+
must have been approved.
14+
15+
To approve a license, a `<ThirdPartyLicense>` node has to be added with a
16+
matching include and a hash of the license file. That hash is communicated for
17+
licenses which lack such a registration.
18+
19+
## Non-compliant
20+
``` xml
21+
<Project Sdk="Microsoft.NET.Sdk">
22+
23+
<PropertyGroup>
24+
<TargetFramework>net8.0</TargetFramework>
25+
</PropertyGroup>
26+
27+
<ItemGroup>
28+
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.6.0.109712" />
29+
</ItemGroup>
30+
31+
</Project>
32+
```
33+
34+
## Compliant
35+
``` xml
36+
<Project Sdk="Microsoft.NET.Sdk">
37+
38+
<PropertyGroup>
39+
<TargetFramework>net8.0</TargetFramework>
40+
</PropertyGroup>
41+
42+
<ItemGroup>
43+
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.6.0.109712" />
44+
</ItemGroup>
45+
46+
<ItemGroup Label="Approved licenses">
47+
<ThirdPartyLicense Include="SonarAnalyzer.CSharp" Hash="ZOAgZmx18wSWq5KpOpWd2bB9123" />
48+
</ItemGroup>
49+
50+
</Project>
51+
```
52+
53+
This rule can detect used licenses in NuGet spec files, but can not be
54+
considered legal advice, nor is this documentation.

rules/Proj0504.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
parent: Licensing
3+
ancestor: Rules
4+
---
5+
6+
# Proj0504: Package license has changed
7+
Using a [NuGet](https://www.nuget.org) package implies that you
8+
and/or your company explicitly agree with the legally binding conditions of the
9+
license and the copyright of the owner of the package.
10+
11+
If a third-party package license comes with a custom license (other than one
12+
specified by the [SPDX](https://spdx.dev)), this rule ensures that the license
13+
did not change unnoticed. It does so by communicating that the hash of the
14+
license is different from the license approved one.
15+
16+
## Non-compliant
17+
``` xml
18+
<Project Sdk="Microsoft.NET.Sdk">
19+
20+
<PropertyGroup>
21+
<TargetFramework>net8.0</TargetFramework>
22+
</PropertyGroup>
23+
24+
<ItemGroup>
25+
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.6.0.109712" />
26+
</ItemGroup>
27+
28+
<ItemGroup Label="Approved licenses">
29+
<ThirdPartyLicense Include="SonarAnalyzer.CSharp" Hash="ADifferentHash" />
30+
</ItemGroup>
31+
32+
</Project>
33+
```
34+
35+
## Compliant
36+
``` xml
37+
<Project Sdk="Microsoft.NET.Sdk">
38+
39+
<PropertyGroup>
40+
<TargetFramework>net8.0</TargetFramework>
41+
</PropertyGroup>
42+
43+
<ItemGroup>
44+
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.6.0.109712" />
45+
</ItemGroup>
46+
47+
<ItemGroup Label="Approved licenses">
48+
<ThirdPartyLicense Include="SonarAnalyzer.CSharp" Hash="ZOAgZmx18wSWq5KpOpWd2bB9123" />
49+
</ItemGroup>
50+
51+
</Project>
52+
```

0 commit comments

Comments
 (0)