Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backdoors, GitHub Package Manager, cleanup. #228

Merged
merged 23 commits into from
Jun 2, 2021
Merged

Conversation

scovetta
Copy link
Member

@scovetta scovetta commented May 30, 2021

This PR has a bunch of updates:

  • Add new backdoor detection rules (based on recent attacks seen).
  • Add preliminary support for Golang, fix GitHub processors (removed libgit2 dependency) (Type initializer error for libgit2sharp on Linux #172).
  • Minor improvements (version sorting, test coverage, nullability)
  • Remove self-contained csproj attribute (was preventing building in Visual Studio, debugging, etc.)

@scovetta scovetta changed the title Add backdoor indicators based on recent research. Backdoors, GitHub Package Manager, cleanup. May 31, 2021
@scovetta scovetta marked this pull request as draft May 31, 2021 05:18
@scovetta scovetta requested review from gfs and jacobmsft May 31, 2021 06:53
@scovetta scovetta marked this pull request as ready for review May 31, 2021 07:51
Fix typos
Copy link
Contributor

@gfs gfs left a comment

Choose a reason for hiding this comment

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

Looks good.

/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
public int Compare(List<string>? x, List<string>? y)
Copy link
Contributor

@gfs gfs Jun 1, 2021

Choose a reason for hiding this comment

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

If you do want to do it this way. I would strongly recommend just converting the numbers into numbers before listing them to make this way simpler.

I reread this and it looks like you are comparing actual strings in here not just numbers.

Copy link
Member Author

Choose a reason for hiding this comment

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

for (int i=0; i<minLength; i++)
{
    if (int.TryParse(x[i], out int xInt) &&
        int.TryParse(y[i], out int yInt))
    {
        if (xInt > yInt) return -1;
        if (yInt > xInt) return 1;
    }
    else
    {
        var compValue = x[i].CompareTo(y[i]);
        if (compValue != 0) return compValue;
    }
}

If the strings are integers (e.g. the 234 in v1.234.56 and the 78 in v1.78.0), then it should compare 234 to 78 as integers and show that 234 comes after it.

(Or maybe I missed something.)

Copy link
Contributor

Choose a reason for hiding this comment

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

I tested and it does not sort integers like that when you pass them as strings. That said the string comparison looks like its only when something is not a number so I think it is OK. My comment was just explaining why I crossed out my initial comment.

> list
List<string>(0) { }
> list.Add("234");
> list.Add("73");
> list.Sort()
> list
List<string>(2) { "234", "73" }

@scovetta scovetta requested a review from daalcant June 1, 2021 17:28
@scovetta
Copy link
Member Author

scovetta commented Jun 1, 2021

@daalcant Could you take a look at the .csproj files (with me setting <SelfContained>false</SelfContained>) to see if we need to adjust the build scripts? This was needed to get the solution to build in Visual Studio.

@daalcant
Copy link
Contributor

daalcant commented Jun 1, 2021

@daalcant Could you take a look at the .csproj files (with me setting <SelfContained>false</SelfContained>) to see if we need to adjust the build scripts? This was needed to get the solution to build in Visual Studio.

I'll need to update the build strategy. I think if we build each project individually then do a self-contained build of the solution it will achieve what we're looking for. After I test locally I'll update this PR.

@daalcant
Copy link
Contributor

daalcant commented Jun 2, 2021

I added some changes to prepare for updating the pipeline build order. I expect builds to fail until I commit the next set of changes; just checking to make sure that tests run as expected.

@daalcant
Copy link
Contributor

daalcant commented Jun 2, 2021

Running into more issues here. Looks like there was a recent breaking change to the way self-contained project references are validated in .NET 5. Going to fiddle with the configurations and the ValidateExecutableReferencesMatchSelfContained property.

https://docs.microsoft.com/en-us/dotnet/core/compatibility/sdk/5.0/referencing-executable-generates-error

@daalcant
Copy link
Contributor

daalcant commented Jun 2, 2021

@scovetta Builds seem to be working again (for now). Unfortunately I'm pretty sure our setup is unsupported and could break in the future. The .NET docs suggest we shouldn't expect to bundle our executables in a single folder the way we have been, which is why we keep running into problems. I'm open to discuss later but I suppose this is fine for the short term.

I performed some basic testing of the framework dependent netcore app and the self-contained Windows and Linux apps. All of the executables run, and I was able to successfully demo oss-download against pkg:cargo/rand on each platform as a spot check. Feel free to merge if this is good enough.

Copy link
Contributor

@daalcant daalcant left a comment

Choose a reason for hiding this comment

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

Reviewed build items, LGTM

@daalcant daalcant linked an issue Jun 2, 2021 that may be closed by this pull request
@scovetta
Copy link
Member Author

scovetta commented Jun 2, 2021

Thanks @daalcant! Merging now.

@scovetta scovetta merged commit 239475b into main Jun 2, 2021
@scovetta scovetta deleted the miscovet/fix-backdoor branch June 2, 2021 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Recent OSS Gadget cannot build on macOS (with or without docker)
3 participants