Skip to content

Conversation

@radekdoulik
Copy link
Member

  • the reason to use the Cecil repo is to be quicker when fixing Cecil
    bugs (usually hit from the XA linker)

  • added "proxy" projects for Xamarin.Android.Cecil and
    Xamarin.Android.Cecil.Mdb libraries

  • the logic was moved from monodroid repo, because Java.Interop is
    1st user of Cecil during the Xamarin Android build process

  • updated all the projects to use the Xamarin.Android.Cecil library
    instead of Mono.Cecil nuget package

<PropertyGroup>
<AssemblyName>$(AssemblyName.Replace('Mono', 'Xamarin.Android'))</AssemblyName>
</PropertyGroup>
<ItemGroup>
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation should be consistent in this file. Either everything should use spaces, or everything should use tabs (use spaces!). Regardless, <PropertyGroup/> and <ItemGroup/> should vertically align, and they don't here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, good catch. This files was moved from monodroid repo. It is good opportunity to fix the indentation, done.

EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.Cecil", "src\Xamarin.Android.Cecil\Xamarin.Android.Cecil.csproj", "{15945D4B-FF56-4BCC-B598-2718D199DD08}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.Cecil.Mdb", "src\Xamarin.Android.Cecil\Xamarin.Android.Cecil.Mdb.csproj", "{C0487169-8F81-497F-919E-EB42B1D0243F}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this go into a src\Xamarin.Android.Cecil.Mdb directory? I'm not sure.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to keep it together in one place, so hopefully it is OK to keep here.

<Target Name="PrepareCecil"
Inputs="$(CecilDirectory)\Mono.Cecil.sln"
Outputs="$(CecilPreparedFlag)">
<Exec Command="cd $(CecilDirectory); ln -sf $(MSBuildThisFileDirectory)\AssemblyInfo.cs Mono.Cecil.AssemblyInfo.cs" />
Copy link
Contributor

Choose a reason for hiding this comment

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

A medium-term (short-term?) goal for the Java.Interop and xamarin-android repos is to "support" building the projects on Windows.

We shouldn't deliberately introduce anything that would prevent that from working. It might not work for other reasons -- e.g. mono builds on Windows are something I'm trying to avoid in xamarin-android, hence the bundle generation & caching -- but we shouldn't deliberately introduce new constructs which we know won't work on Windows.

ln -s is such a construct. Perhaps it should use the <Copy/> task?

Unfortunately, patch is also such a construct. I'm not sure how best to handle that; I guess we should keep it for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, I used Copy instead and added the files to Inputs so that the target is rebuilt when these are changed.

<Name>Xamarin.Android.Tools.AnnotationSupport</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
Copy link
Contributor

Choose a reason for hiding this comment

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

Odd that this <ItemGroup/> was re-ordered...

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that remained there after my small fight with msbuild :-) Fixed.

@radekdoulik
Copy link
Member Author

OK, the patch is updated and hopefully ready to merge.

Outputs="$(CecilPreparedFlag)">
<Copy SourceFiles="AssemblyInfo.cs" DestinationFiles="$(CecilDirectory)\Mono.Cecil.AssemblyInfo.cs" />
<Copy SourceFiles="Mono.Cecil.overrides" DestinationFolder="$(CecilDirectory)" />
<Exec Command="cd $(CecilDirectory); git reset --hard" />
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be necessary.

Instead, we should add a top-level make prepare target, a'la xamarin-android, and should also contain/handle the nuget restore logic.

 - the reason to use the Cecil repo is to be quicker when fixing Cecil
   bugs (usually hit from the XA linker)

 - added "proxy" projects for Xamarin.Android.Cecil and
   Xamarin.Android.Cecil.Mdb libraries

 - the logic was moved from monodroid repo, because Java.Interop is
   1st user of Cecil during the Xamarin Android build process

 - updated all the projects to use the Xamarin.Android.Cecil library
   instead of Mono.Cecil nuget package
@jonpryor jonpryor merged commit f44a11f into dotnet:master Nov 17, 2016
@kzu
Copy link

kzu commented Nov 18, 2016

Changing the assembly name of Cecil does not require proxy projects or assembly patching. See dotnet/cecil#6.

On XVS, we just add the overrides targets to our external root folder, like so: https://github.com/xamarin/XamarinVS/blob/master/External/Mono.Cecil.overrides.

And we also add InternalsVisisbleTo accordingly: https://github.com/xamarin/XamarinVS/blob/master/External/Cecil.AssemblyInfo.cs

radekdoulik added a commit that referenced this pull request Nov 24, 2016
Use cecil repo instead of nuget package.

The reason to use the Cecil repo is to be quicker when fixing Cecil
bugs (usually hit from the XA linker).

Added "proxy" projects for `Xamarin.Android.Cecil` and
`Xamarin.Android.Cecil.Mdb` libraries. We use these names because
they match the currently used "Vendorized" Cecil which is
distributed with commercial Xamarin.Android.

Updated all the projects to use the `Xamarin.Android.Cecil` library
instead of `Mono.Cecil` nuget package.
jonpryor added a commit to jonpryor/java.interop that referenced this pull request Feb 9, 2021
Context: https://medium.com/@alex.birsan/dependency-confusion-4a5d60fec610
Context: https://azure.microsoft.com/en-us/resources/3-ways-to-mitigate-risk-using-private-package-feeds/
Context: https://devdiv.visualstudio.com/DevDiv/_wiki/wikis/DevDiv.wiki/12676/ncident-help-for-Substitution-attack-risk-from-multiple-package-feeds

Changes: dotnet/android-tools@26d65d9...63510cf

  * dotnet/android-tools@63510cf: [ci] Update packageSources in NuGet.config (dotnet#105)
  * dotnet/android-tools@83ed0a4: Bump ta xamarin/LibZipSharp/1.0.22@9f563dd1 (dotnet#104)
  * dotnet/android-tools@8ea78a4: Add Microsoft.Android.Build.BaseTasks project (dotnet#101)
  * dotnet/android-tools@b2d9fdf: [NDK] Locate and select only compatible NDK versions (dotnet#103)
  * dotnet/android-tools@5ff1702: [tests] Use dotnet test to run AndroidSdk-Tests (dotnet#102)
  * dotnet/android-tools@ad80a42: [ci] Use the new "main" default branch (dotnet#100)

There is a Package Substitution Attack inherent in NuGet, whereby
if multiple package sources provide packages with the same name,
it is *indeterminate* which package source will provide the package.

For example, consider the [`XliffTasks` package][0], currently
provided from the [`dotnet-eng`][1] feed, and *not* present in the
NuGet.org feed.  If a "hostile attacker" submits an `XliffTasks`
package to NuGet.org, then we don't know, and cannot control, whether
the build will use the "hostile" `XliffTasks` package from NuGet.org
or the "desired" package from `dotnet-eng`.

There are two ways to prevent this attack:

 1. Use `//packageSources/clear` and have *only one*
    `//packageSources/add` entry in `NuGet.config`

 2. Use `//packageSources/clear` and *fully trust* every
    `//packageSources/add` entry in `NuGet.config`.
    `NuGet.org` *cannot* be a trusted source, nor can any feed
    location which allows "anyone" to add new packages, nor can
    a feed which itself contains [upstream sources][2].

As the `XliffTasks` package is *not* in `NuGet.org`, option (1)
isn't an option.  Go with option (2), using the existing
`dotnet-eng` source and the new *trusted* [`dotnet-public`][3]
package source.

[0]: https://github.com/dotnet/xliff-tasks
[1]: https://dev.azure.com/dnceng/public/_packaging?_a=feed&feed=dotnet-eng
[2]: https://docs.microsoft.com/en-us/azure/devops/artifacts/concepts/upstream-sources?view=azure-devops
[3]: https://dev.azure.com/dnceng/public/_packaging?_a=feed&feed=dotnet-public
jonpryor added a commit to jonpryor/java.interop that referenced this pull request Feb 9, 2021
Context: https://medium.com/@alex.birsan/dependency-confusion-4a5d60fec610
Context: https://azure.microsoft.com/en-us/resources/3-ways-to-mitigate-risk-using-private-package-feeds/
Context: https://devdiv.visualstudio.com/DevDiv/_wiki/wikis/DevDiv.wiki/12676/ncident-help-for-Substitution-attack-risk-from-multiple-package-feeds

Changes: dotnet/android-tools@26d65d9...479931c

  * dotnet/android-tools@479931c [build] Move global.json file to root directory (dotnet#106)
  * dotnet/android-tools@63510cf: [ci] Update packageSources in NuGet.config (dotnet#105)
  * dotnet/android-tools@83ed0a4: Bump ta xamarin/LibZipSharp/1.0.22@9f563dd1 (dotnet#104)
  * dotnet/android-tools@8ea78a4: Add Microsoft.Android.Build.BaseTasks project (dotnet#101)
  * dotnet/android-tools@b2d9fdf: [NDK] Locate and select only compatible NDK versions (dotnet#103)
  * dotnet/android-tools@5ff1702: [tests] Use dotnet test to run AndroidSdk-Tests (dotnet#102)
  * dotnet/android-tools@ad80a42: [ci] Use the new "main" default branch (dotnet#100)

There is a Package Substitution Attack inherent in NuGet, whereby
if multiple package sources provide packages with the same name,
it is *indeterminate* which package source will provide the package.

For example, consider the [`XliffTasks` package][0], currently
provided from the [`dotnet-eng`][1] feed, and *not* present in the
NuGet.org feed.  If a "hostile attacker" submits an `XliffTasks`
package to NuGet.org, then we don't know, and cannot control, whether
the build will use the "hostile" `XliffTasks` package from NuGet.org
or the "desired" package from `dotnet-eng`.

There are two ways to prevent this attack:

 1. Use `//packageSources/clear` and have *only one*
    `//packageSources/add` entry in `NuGet.config`

 2. Use `//packageSources/clear` and *fully trust* every
    `//packageSources/add` entry in `NuGet.config`.
    `NuGet.org` *cannot* be a trusted source, nor can any feed
    location which allows "anyone" to add new packages, nor can
    a feed which itself contains [upstream sources][2].

As the `XliffTasks` package is *not* in `NuGet.org`, option (1)
isn't an option.  Go with option (2), using the existing
`dotnet-eng` source and the new *trusted* [`dotnet-public`][3]
package source.

[0]: https://github.com/dotnet/xliff-tasks
[1]: https://dev.azure.com/dnceng/public/_packaging?_a=feed&feed=dotnet-eng
[2]: https://docs.microsoft.com/en-us/azure/devops/artifacts/concepts/upstream-sources?view=azure-devops
[3]: https://dev.azure.com/dnceng/public/_packaging?_a=feed&feed=dotnet-public
jonpryor added a commit that referenced this pull request Feb 9, 2021
…796)

Context: https://medium.com/@alex.birsan/dependency-confusion-4a5d60fec610
Context: https://azure.microsoft.com/en-us/resources/3-ways-to-mitigate-risk-using-private-package-feeds/
Context: https://devdiv.visualstudio.com/DevDiv/_wiki/wikis/DevDiv.wiki/12676/ncident-help-for-Substitution-attack-risk-from-multiple-package-feeds

Changes: dotnet/android-tools@26d65d9...479931c

  * dotnet/android-tools@479931c [build] Move global.json file to root directory (#106)
  * dotnet/android-tools@63510cf: [ci] Update packageSources in NuGet.config (#105)
  * dotnet/android-tools@83ed0a4: Bump ta xamarin/LibZipSharp/1.0.22@9f563dd1 (#104)
  * dotnet/android-tools@8ea78a4: Add Microsoft.Android.Build.BaseTasks project (#101)
  * dotnet/android-tools@b2d9fdf: [NDK] Locate and select only compatible NDK versions (#103)
  * dotnet/android-tools@5ff1702: [tests] Use dotnet test to run AndroidSdk-Tests (#102)
  * dotnet/android-tools@ad80a42: [ci] Use the new "main" default branch (#100)

There is a Package Substitution Attack inherent in NuGet, whereby
if multiple package sources provide packages with the same name,
it is *indeterminate* which package source will provide the package.

For example, consider the [`XliffTasks` package][0], currently
provided from the [`dotnet-eng`][1] feed, and *not* present in the
NuGet.org feed.  If a "hostile attacker" submits an `XliffTasks`
package to NuGet.org, then we don't know, and cannot control, whether
the build will use the "hostile" `XliffTasks` package from NuGet.org
or the "desired" package from `dotnet-eng`.

There are two ways to prevent this attack:

 1. Use `//packageSources/clear` and have *only one*
    `//packageSources/add` entry in `NuGet.config`

 2. Use `//packageSources/clear` and *fully trust* every
    `//packageSources/add` entry in `NuGet.config`.
    `NuGet.org` *cannot* be a trusted source, nor can any feed
    location which allows "anyone" to add new packages, nor can
    a feed which itself contains [upstream sources][2].

As the `XliffTasks` package is *not* in `NuGet.org`, option (1)
isn't an option.  Go with option (2), using the existing
`dotnet-eng` source and the new *trusted* [`dotnet-public`][3]
package source.

[0]: https://github.com/dotnet/xliff-tasks
[1]: https://dev.azure.com/dnceng/public/_packaging?_a=feed&feed=dotnet-eng
[2]: https://docs.microsoft.com/en-us/azure/devops/artifacts/concepts/upstream-sources?view=azure-devops
[3]: https://dev.azure.com/dnceng/public/_packaging?_a=feed&feed=dotnet-public
@github-actions github-actions bot locked and limited conversation to collaborators Apr 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants