Giter VIP home page Giter VIP logo

aleph1.skeletons's People

Contributors

726b avatar avrahamcool avatar dependabot-preview[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

aleph1.skeletons's Issues

[webapi] wrong CorrelationID when using async/await

activityID is changed when returning from an async operation.
we should use a custom field to maintain a reliable CorrelationID.

in globalASAX
HttpContext.Current.Items["CorrelationID"] = Guid.NewGuid();
---------------
in config
<column name="CorrelationID" layout="${aspnet-item:variable=CorrelationID}" />
---------------
install: NLog.web

[webapi] missing disable CORS for varient configs

    <add xdt:Transform="SetAttributes" xdt:Locator="Match(key)" key="EnableCORS" value="false" />
    <add xdt:Transform="Remove" xdt:Locator="Match(key)" key="Origins" />
    <add xdt:Transform="Remove" xdt:Locator="Match(key)" key="Headers" />
    <add xdt:Transform="Remove" xdt:Locator="Match(key)" key="Methods" />
    <add xdt:Transform="Remove" xdt:Locator="Match(key)" key="ExposedHeaders" />

[WebAPI.WebAPI] delete old files before publish

            PublishUrl = new Uri(Path.Combine(Directory.GetCurrentDirectory(), PublishUrl)).LocalPath;
            if (!Directory.Exists(PublishUrl))
            {
                LogMessage = "Directory " + PublishUrl + " not found - Skipping Backup.";
                return true;
            }

            const int MAX_BACKUPS = 3;
            string backupFolder = new Uri(Path.Combine(PublishUrl, "./Backup")).LocalPath;
            string LogsFolder = new Uri(Path.Combine(PublishUrl, "./Logs")).LocalPath;


            string[] pathsToExclude = new[] { backupFolder, LogsFolder };

            IEnumerable<FileInfo> filesToBackup = new DirectoryInfo(PublishUrl)
                .EnumerateFiles("*", SearchOption.AllDirectories)
                .Where(file => pathsToExclude.All(toExclude => !file.FullName.StartsWith(toExclude)));

            DateTime? lastUpdatedFileDate = filesToBackup
                .Select<FileInfo, DateTime?>(file => file.LastWriteTime)
                .DefaultIfEmpty()
                .Max();

            if (!lastUpdatedFileDate.HasValue)
            {
                LogMessage = "Directory " + PublishUrl + " was empty - Skipping Backup.";
                return true;
            }

            Directory.CreateDirectory(backupFolder);

            string backupName = lastUpdatedFileDate.Value.ToString(@"yyyy-MM-dd HH.mm.ss");

            Uri backupZipPathUri = new Uri(Path.Combine(backupFolder, backupName + ".zip"));
            if (File.Exists(backupZipPathUri.LocalPath))
            {
                LogMessage = "Backup " + backupZipPathUri.AbsoluteUri + " already exists - Skipping Backup.";
            }
            else
            {
                string backupPath = Path.Combine(backupFolder, backupName);
                Directory.CreateDirectory(backupPath);
                foreach (FileInfo item in filesToBackup)
                {
                    string newPath = item.FullName.Replace(PublishUrl, backupPath);
                    Directory.CreateDirectory(Directory.GetParent(newPath).FullName);
                    item.CopyTo(item.FullName.Replace(PublishUrl, backupPath));
                }
                ZipFile.CreateFromDirectory(backupPath, backupZipPathUri.LocalPath);
                Directory.Delete(backupPath, true);

                FileInfo[] oldBackups = new DirectoryInfo(backupFolder)
                    .GetFiles("*.zip");

                foreach (FileInfo oldBackup in oldBackups
                        .OrderBy(file => file.CreationTime)
                        .Take(oldBackups.Length - MAX_BACKUPS))
                {
                    oldBackup.Delete();
                }

                LogMessage = "Backup created at " + backupZipPathUri.AbsoluteUri;
            }

            foreach (FileInfo file in filesToBackup)
            {
                file.Delete();
            }

            IEnumerable<DirectoryInfo> directoriesToDelete = new DirectoryInfo(PublishUrl)
                .EnumerateDirectories("*", SearchOption.TopDirectoryOnly)
                .Where(dir => pathsToExclude.All(toExclude => !dir.FullName.StartsWith(toExclude)));

            foreach (DirectoryInfo dir in directoriesToDelete)
            {
                dir.Delete(true);
            }

            return true;

[Webapi] restrict access to Logs and backup

<system.webServer>
    <modules>
      <remove name="WebDAVModule" />
    </modules>
    <handlers>
      <remove name="WebDAV" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
    <httpProtocol>
      <customHeaders>
        <clear />
      </customHeaders>
    </httpProtocol>
    <security>
      <requestFiltering>
        <hiddenSegments>
          <add segment="Logs"/>
          <add segment="Backup"/>
          <add segment="Documentation"/>
        </hiddenSegments>
      </requestFiltering>
    </security>
  </system.webServer>

[Client] IdleTimeOut causes input of type number to behave

IdleTimeOut package adds a default "mousewheel" event to the window.
this is somehow interfering with input of type number. (scrolling on a number type causes the numbers to change.)

can be fix by patching the library.
need more investigation.

Handle better csproj

<DocumentationFile>..\Output\$(Configuration)\Documentation\ProjName.xml</DocumentationFile>

Use AssemblyName instead of literal name

[WebAPI.WebAPI] Fix Content Security Policy header

Content Security Policy header should contain the following values:

default-src 'none';
base-uri 'none';
object-src 'none';
frame-ancestors 'none';
connect-src 'self' https://www.google.com;
script-src 'self' 'strict-dynamic' 'sha256-CHANGE_THIS' https://www.google.com https://www.gstatic.com;
style-src 'self' https://www.gstatic.com 'unsafe-inline';
frame-src 'self' https://www.google.com;
img-src 'self' data: blob: https://www.gstatic.com;
font-src 'self' data: blob: https://fonts.gstatic.com;
worker-src 'self' https://www.google.com https://www.gstatic.com;
child-src 'self' https://www.google.com https://www.gstatic.com;
media-src 'self';
form-action 'self';
require-trusted-types-for 'script'

Google reCAPTCHA URLs are included and will work by default.

Also, please note that in order to @import fonts from Google Fonts, you should add https://fonts.googleapis.com to style-src.

References:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.