Skip to content

Do not replace base64 encoded content from output #464

@BobSilent

Description

@BobSilent

With commit 8043e66 - avoid storing base64 encoded binary responses in smoke tests (#65)

the base64 encoded content gets removed from the output which does not allow me to create PRs.

When trying to create PR from the result, like shown here: https://github.com/dependabot/example-cli-usage/blob/bf8e4065366e2cd4d2317dd58de86fee0751379b/create.sh#L47-L49
I am missing the base64 encoded content and overwrite the data with just the hash value instead of the updated file content.

sample content in YAML, thats how it should look like

- content: |
    <Project Sdk="Microsoft.NET.Sdk">

      <PropertyGroup>
        <TargetFramework>net9.0</TargetFramework>
      </PropertyGroup>

      <ItemGroup>
        <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
        <PackageReference Include="NSubstitute" Version="5.3.0" />
        <PackageReference Include="xunit" Version="2.9.3" />
        <PackageReference Include="xunit.runner.visualstudio" Version="3.1.1">
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
          <PrivateAssets>all</PrivateAssets>
        </PackageReference>
        <PackageReference Include="coverlet.collector" Version="6.0.4">
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
          <PrivateAssets>all</PrivateAssets>
        </PackageReference>
      </ItemGroup>

    </Project>
  content_encoding: utf-8
  deleted: false
  directory: /Tools/OtherClient.Tests
  name: OtherClient.Tests.csproj
  operation: update
  support_file: false
  type: file

but unfortunately I get for some files such a result:

  - content: e6cfa952d08a76f563028084ac5e6cc6764c6ba8b8eb9a5fca50a4c3eb9267ce
    content_encoding: sha256
    deleted: false
    directory: /Tools/Client.Tests
    name: Client.Tests.csproj
    operation: update
    support_file: false
    type: file

I analyzed, that it depends on some file encoding how the content is handled:
For example, the nuget updater supports file in UTF8 with BOM like that:
https://github.com/dependabot/dependabot-core/blob/6506a0d19b63e50794d63b3cb7428a81363dd825/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ModifiedFilesTracker.cs#L94-L107

if a BOM encoding is found, the implementation base64 hashes the content. And this content gets removed by the default implemention in CLI.

It would be good if this behavior could be enabled by the mentioned smoke tests, and is disabled by default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions