Skip to content

Instantly share code, notes, and snippets.

View kant2002's full-sized avatar

Andrii Kurdiumov kant2002

View GitHub Profile
@kant2002
kant2002 / story.md
Created July 8, 2022 08:44
Why Security is hard

I have very specific view that ASP.NET Core security is probably fine, but overall industry guidelines are meh and tailored for security people. Almost all issues which I have with implementing security was due to other external factors, like:

  • lack of resources
  • Lack of training in securing solution
  • Lack of time to find proper solution
  • Lots of jargonism and abstractiosn in describing security.

My observvations applied to cases where solo-developer or team of developers responsible for implementing security for their "product". That can be devs in small, mid sized org, or teams in large orgs where security department demands some techniquest to be employed. Or even better goverment agencies which everywhere in the world underfunded and do not have enough resources for securing things.

@kant2002
kant2002 / sample.cs
Last active June 13, 2022 12:59
NativeAOT and DI
namespace InternalNamespace.Nested;
using Microsoft.Extensions.DependencyInjection;
class DependentTestService {}
class TestService
{
public TestService(DependentTestService dependency) {}
}
@kant2002
kant2002 / original.cs
Last active January 31, 2022 19:41
Тестирование времени в C#
void EnrichRequest(Request request)
{
var days = configurationService.GetValidDurationInDays();
request.ValidTo = request.ValidTo ?? DateTime.Now.AddDays(days);
}
// Супер легко использовать
EnrichRequest(request);
/*
@kant2002
kant2002 / instructions.txt
Last active January 25, 2022 04:04
F# test app for reflection-free code
# one time
./build.sh
# when make changes to compiler
dotnet build src/fsharp/fsc/fsc.fsproj
# Compile test application
artifacts/bin/fsc/Debug/net5.0/fsc ../test.fs --targetprofile:netcore --target:exe --out:test.exe
dotnet test.exe
@kant2002
kant2002 / Discussion.md
Created December 20, 2021 12:29
Jit in C# discussion

MS: Michal Strehovlky AK: Andrii Kurdiumov

MS: yeah well there's still some things that can only be done in C/C++ and cannot be done in C#

AK: I understand that life not all rosy. but when I see how you bend C# to your wishes, I think a lot of can be done.

I trying to build standalone Jit without relying on infrastructure too much to be able mix a bit of C#, but so far it's hard.

@kant2002
kant2002 / rd.xml
Created November 20, 2021 03:44
RTSP and NativeAOT
<?xml version="1.0" encoding="utf-8" ?>
<Directives>
<Application>
<Assembly Name="Microsoft.AspNetCore.Mvc.Razor">
<Type Name="Microsoft.AspNetCore.Mvc.ApplicationParts.ConsolidatedAssemblyApplicationPartFactory" Dynamic="Required All" />
</Assembly>
<Assembly Name="Microsoft.AspNetCore.Mvc.Core" Dynamic="Required All">
<Type Name="Microsoft.Extensions.Internal.PropertyHelper">
<Method Name="CallNullSafePropertyGetter" Dynamic="Required">
<GenericArgument Name="VideoMonitoring.Pages.ErrorModel, VideoMonitoring" />
@kant2002
kant2002 / conversation.md
Last active September 15, 2021 04:30
Tanner Gooding vs SingleAccretion

[6:31] SingleAccretion: (Completely unrelated)

Let's test my API design ability. What is the difference between SetHWIntrinsic and ChangeHWIntrinsic?

[6:33] Tanner Gooding: I would assume Change might do other transformations required if they aren't directly compatible or something

I don't particularly like the name 😄

[6:37] SingleAccretion: (Alternatives are very welcome of course)

@kant2002
kant2002 / paket.dependencies
Last active July 29, 2021 19:08
F# and NativeAOT
source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json
nuget Microsoft.DotNet.ILCompiler ~> 6.0.0-rc.1
@kant2002
kant2002 / Dockerfile
Created July 4, 2021 07:52
NativeAOTDocker
FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build
WORKDIR /app
COPY HelloWorldStatic.csproj .
COPY nuget.config .
RUN dotnet restore --runtime linux-musl-x64 HelloWorldStatic.csproj
RUN apk add clang libexecinfo binutils musl-dev build-base zlib-static
COPY . .
RUN dotnet publish -c Release -r linux-musl-x64 -o out HelloWorldStatic.csproj
@kant2002
kant2002 / BasicComWrappers.cs
Last active June 18, 2021 14:26
DirectX and NativeAOT
unsafe partial class DirectXComWrappers : ComWrappers
{
protected override unsafe ComInterfaceEntry* ComputeVtables(object obj, CreateComInterfaceFlags flags, out int count)
{
throw new NotImplementedException();
}
protected override object CreateObject(IntPtr externalComObject, CreateObjectFlags flags)
{
return new UniversalWrapper(externalComObject);