<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Andreas Sommarström on Medium]]></title>
        <description><![CDATA[Stories by Andreas Sommarström on Medium]]></description>
        <link>https://medium.com/@andreas-sommarstrom?source=rss-2d1f31c556c0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*cQ2uPs6DmltnaoAXL52SOQ.png</url>
            <title>Stories by Andreas Sommarström on Medium</title>
            <link>https://medium.com/@andreas-sommarstrom?source=rss-2d1f31c556c0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 15:37:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@andreas-sommarstrom/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Get started with a private NuGet server for .NET packages in 5 minutes]]></title>
            <link>https://andreas-sommarstrom.medium.com/get-started-with-a-private-nuget-server-for-net-packages-in-5-minutes-d14a72912124?source=rss-2d1f31c556c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/d14a72912124</guid>
            <category><![CDATA[visual-studio]]></category>
            <category><![CDATA[nuget]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[jetbrains-rider]]></category>
            <dc:creator><![CDATA[Andreas Sommarström]]></dc:creator>
            <pubDate>Wed, 16 Feb 2022 14:08:15 GMT</pubDate>
            <atom:updated>2022-02-16T14:08:15.402Z</atom:updated>
            <content:encoded><![CDATA[<h3>Get started with a private NuGet server for .NET packages in 5 minutes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*WFgmTsUY4YRTpzyeJxxrww.png" /></figure><p><strong><em>.NET, the Microsoft supported open source framework, is celebrating 20 years!</em></strong> <strong><em>And wow, has there been a lot of changes in .NET and software development in general in those 20 years.</em></strong></p><p>Where before every piece of code and functionality needed to be produced in-house, there are now millions of available packages in central repositories for users to consume — with obvious efficiency advantages.</p><p><strong>NuGet</strong>, the package manager for .NET, allow developers to easily share and consume reusable packages dependencies for their C#, F# and Visual Basic .NET applications. With <em>nuget.org</em> providing easy access to over 4 millions versions, both from Microsoft and open source developers.</p><p>But using more and more open source components also puts advanced requirements on keeping control over the code used. With security attacks targeting the open source software supply chain increased by 650% in 2021 alone it is more important than ever for organizations to protect the software they build — and every developer environment, CI/CD system and server.</p><p><em>Need a private NuGet feed for both internal .NET packages and public dependencies? </em><a href="https://bytesafe.dev/"><strong><em>Bytesafe</em></strong></a><em> feeds are cloud hosted, and compatible with </em><strong><em>Visual Studio</em></strong><em>, </em><strong><em>JetBrains Rider</em></strong><em> and the </em><strong><em>NuGet CLI</em></strong><em>. You can get started instantly and build your projects securely with the tools of your choice.</em></p><h3>Five reasons to use a private NuGet feed</h3><p>A private NuGet source, a necessity for code sharing and keeping unwanted dependencies out of your organization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/0*1c4VDLnIsGBdunt6.png" /></figure><ol><li><strong>Secure source for open source dependencies</strong>. Don’t allow free entry for untrusted code from public sources. Include approved dependencies, according to your rules.</li><li><strong>Share internal packages</strong>. Authorized and personal access to your organization’s private packages.</li><li><strong>Cache/proxy public packages</strong>. Don’t depend directly on public repositories like nuget.org. Make sure your organization’s packages are always available when you need them.</li><li><strong>Enforce security policies</strong>. Enforce your business policies with the <a href="https://bytesafe.dev/dependency-firewall/">Dependency Firewall</a>. Scan for vulnerabilities and automatically block access to unwanted and untrusted dependencies.</li><li><strong>License compliance</strong>. Accurately identify licenses used in your organization. Customize license policies to match your unique needs and block non-compliant licenses.</li></ol><h3>Getting started with a private NuGet feed</h3><p>Using a private NuGet feed instead of the default package source is easy. With some simple config you can have your IDE’s like <strong>Visual Studio</strong> and <strong>JetBrains Rider</strong> fetch dependencies from a private feed in place of <em>nuget.org</em>.</p><p>On top of IDE support the <strong>nuget</strong> package management tool has full support for private feeds, both as a target when deploying packages or as a package source for dependencies.</p><blockquote>These steps assume users have access to a Bytesafe workspace. If not — <a href="https://login.bytesafe.dev/signup">Sign up</a> for Bytesafe today for free.</blockquote><h3>Create a NuGet feed</h3><p>To get started you need to create a NuGet registry (the Bytesafe equivalent of a feed or repository) and configure access to it in your client of choice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YYM6GqG_I8VJfLv-.png" /></figure><p>After you have created your NuGet registry, you need to add a package source to your configuration.</p><p>Create an access token in Bytesafe and add it together with the registry URL to your list of approved package sources. The access token ensures only intended users have access to packages stored in Bytesafe.</p><p>Visual Studio &amp; JetBrains Rider users can do this directly in the NuGet package tool in their IDE (see sections on IDE integrations for more details). CLI users can alternatively add the package source using nuget.</p><pre># Add the URL, username and access token (password) to your nuget sources</pre><pre><strong>$ nuget sources add -Name {REGISTRY} -Source </strong><a href="https://{workspace}.bytesafe.dev/nuget/%7BREGISTRY%7D/index.json"><strong>https://{WORKSPACE}.bytesafe.dev/nuget/{REGISTRY}/index.json</strong></a><strong> -Username bytesafe -Password {TOKEN}</strong></pre><p>Bytesafe provides contextual and copy-paste ready instructions on how to access your private NuGet feed.</p><p>The package source information will be added to the NuGet.Config file (used by both nuget and IDE’s). For more information on sources and the NuGet config file, see <a href="https://docs.bytesafe.dev/package-managers/nuget/#configuring-nuget-to-access-bytesafe">NuGet</a> in the Bytesafe documentation.</p><h3>Publish a NuGet package</h3><p>NuGet packages can be added to your private NuGet feed using nuget push or by uploading the package files manually.</p><pre># To publish packages using nuget set an apikey for the source</pre><pre><strong>$ nuget setapikey {TOKEN} -Source {REGISTRY}</strong></pre><pre>…</pre><p>With your source configured you can publish packages to your private feed for other internal developers or CI/CD to access.</p><pre># Create a nuget package according to project files</pre><pre><strong>$ nuget pack</strong></pre><pre>…</pre><pre># Publish package to registry using nuget. Replace {REGISTRY} with source name</pre><pre><strong>$ nuget push {PACKAGE} -Source {REGISTRY}</strong></pre><pre>…</pre><h3>Restoring NuGet project dependencies</h3><p>With the public NuGet Gallery (nuget.org) configured as an <a href="https://docs.bytesafe.dev/package-managers/nuget/#proxy-nugetorg-as-an-upstream">upstream</a>, Bytesafe will proxy public dependencies and pull any required (and allowed) version into your private NuGet feed.</p><p>To make sure security features are not bypassed it’s recommended to disable <em>nuget.org</em> as a package source in the NuGet.Config (the package manager fetches packages from all enabled sources).</p><pre># Disable nuget.org as a package source</pre><pre><strong>$ nuget sources disable -Name nuget.org</strong></pre><pre>…</pre><p>There are multiple ways to specify project dependencies. I prefer package references (&lt;PackageReference&gt;) in the project file (.csproj).</p><pre>&lt;! — Example package reference in .csproj file --&gt;<br>&lt;ItemGroup&gt;<br>   &lt;! — … --&gt;<br>   &lt;PackageReference Include=”Newtonsoft.Json” Version=”13.0.1&quot; /&gt;<br>   &lt;! — … --&gt;<br>&lt;/ItemGroup&gt;</pre><p>With project dependencies added to the project, run the nuget restore command to restore project dependencies.</p><pre># Restore package dependencies from Bytesafe</pre><pre><strong>$ nuget restore -Source {REGISTRY}</strong></pre><blockquote>Most IDE’s restore project dependencies by default on project startup or when detecting changes.</blockquote><h3>Using Visual Studio with your private NuGet feed</h3><p>Visual Studio is an integral part of the .NET ecosystem and the default IDE for many .NET developers.</p><p>Private NuGet registries can easily be integrated as a package source in Visual Studio. Pre-existing NuGet.Config files will be identified by Visual Studio and used to configure package sources for NuGet Package Manager.</p><h3>Adding a source manually inside Visual Studio</h3><p>Add the Name, URL and credentials for the registry as the source in the Visual Studio configuration. Access Package Sources in the options (<strong>Windows</strong>: <em>NuGet Package Manager &gt; Package Sources</em> / <strong>Mac</strong>: <em>NuGet &gt; Sources</em>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*hUmpgMZilh8wzYVV.png" /></figure><p>With the source added, packages are automatically able to be restored and updated in Visual Studio using your Bytesafe NuGet registry.</p><p>Any packages available in the private feed will also be available to browse and search in Visual Studio.</p><blockquote><strong>Visual Studio Code</strong> and some distribution of Visual Studio manage private sources using the nuget cli.</blockquote><h3>Using JetBrains Rider with your private NuGet feed</h3><p>JetBrains Rider is the main alternative to Visual Studio for many teams. Like with Visual Studio, private NuGet feeds are easily integrated as a package source for JetBrains Rider.</p><p>It’s recommended for users to add Bytesafe as a new package source directly in JetBrains Rider to avoid conflicts. Some distributions lack support for encrypted passwords from NuGet.Config.</p><h3>Adding a source manually inside JetBrains Rider</h3><p>Add the Name, URL and credentials for the new feed in the NuGet Sources configuration.</p><p>Access the NuGet Tool window from the bottom toolbar or by right-clicking any project dependency and select <em>Manage NuGet Packages</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*V5v9OnTtPW1SJSNH.png" /></figure><p>With the new source added, packages are able to be browsed, restored and updated in Rider using your private NuGet server.</p><h3>Want to know more about Bytesafe private NuGet feeds?</h3><p>Visit <a href="https://bytesafe.dev/nuget/">Bytesafe for NuGet /.NET</a> to learn more. Want to know more about secure supply chains — read more about our <a href="https://bytesafe.dev/dependency-firewall/">firewall for dependencies</a>.</p><blockquote>Want to try Bytesafe? <a href="https://login.bytesafe.dev/signup">Sign up</a> and get started today for free.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d14a72912124" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Host & Secure your Java dependencies in 5 minutes with a Private Maven repository]]></title>
            <link>https://systemweakness.com/host-secure-your-java-dependencies-in-5-minutes-with-a-private-maven-repository-1760176710a4?source=rss-2d1f31c556c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/1760176710a4</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[maven]]></category>
            <category><![CDATA[gradle]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Andreas Sommarström]]></dc:creator>
            <pubDate>Wed, 05 Jan 2022 17:59:12 GMT</pubDate>
            <atom:updated>2022-01-13T08:53:23.621Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*ZfyI_X2B49huv9DX.png" /></figure><p>Maven is a build tool to manage <strong>Java</strong>, <strong>Kotlin</strong>, <strong>Scala,</strong> or similar JVM-based languages projects — including all its dependencies, both open source and private. A great way to make sure your organization uses trusted and approved dependencies is to use a <strong>private Maven repository</strong> — and it’s no more complicated than using the default repository.</p><p><strong>The two main reasons to use private Maven repositories for your JVM packages:</strong></p><ol><li><em>Secure source for open source dependencies</em>. With 1300+ public repositories and over 24 million Java artifacts, organizations need to control the code they are using — and not allow free entry of untrusted components.</li><li><em>Distribute internal components</em>. With a wide range of applications that depend on each other, organizations require private repositories to share code between services while keeping artifacts private and secure.</li></ol><p>Protect your software supply chain and make sure every developer and CI/CD system uses trusted dependencies from a single secure source. With hundreds of automated CI/CD pipelines and decentralized developers this is not an easy task — but definitely achievable with the right tools.</p><p>With the recent disclosures of critical vulnerabilities in the widely used open-source framework log4j, this is more relevant than ever.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*9w6T2gEPTjkMXcNKcs-ehg.png" /><figcaption>Vulnerable version of log4j automatically quarantined by the Bytesafe Dependency Firewall, preventing it from use</figcaption></figure><p>The exploits in <a href="https://www.cisa.gov/uscert/apache-log4j-vulnerability-guidance">log4j</a> have once again stressed the need to keep track of open source dependencies — <em>else risk being exploited by vulnerabilities that could give full server control</em>.</p><p><strong>This post describes how you easily set up a secure and private Maven repository — so you can stay in control of the dependencies you are using.</strong></p><p><em>Require a private Maven repository? </em><a href="https://bytesafe.dev/maven/"><strong><em>Bytesafe</em></strong></a><em> repositories are compatible with both</em> <strong><em>Maven</em></strong><em> and </em><strong><em>Gradle</em></strong> <em>— hosted so you can get started instantly without having to think of infrastructure.</em></p><h3>Getting started with a secure Maven repository</h3><p>With minimal configuration, your build clients can fetch trusted dependencies from your private repository instead of relying on (the default) Maven Central.</p><p>The popular build tools Maven &amp; Gradle fully support private repositories, both as the target when deploying packages or as the source when fetching dependencies.</p><h3>Create a Maven repository</h3><p>To get started you need to create a Maven repository and configure access to it for your client of choice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WIYnTnbEpXRH6hPELY1s2Q.png" /></figure><p>After you have created your Maven repository, you need to add an access token to your project. The access token ensures only intended users have access to packages stored in the private registry.</p><p>Create an access token and add it to your list of repositories in your configuration file for Maven ( settings.xml).</p><pre>&lt;!-- Add the access token and id configuration to settings.xml --&gt;</pre><pre>&lt;servers&gt; <br>    &lt;server&gt;<br>        &lt;id&gt;{MAVEN-REGISTRY}&lt;/id&gt;<br>        &lt;username&gt;{USER}&lt;/username&gt;<br>        &lt;password&gt;{ACCESS-TOKEN}&lt;/password&gt;<br>        &lt;configuration&gt;<br>            &lt;httpConfiguration&gt;<br>                &lt;all&gt;<br>                    &lt;usePreemptive&gt;true&lt;/usePreemptive&gt;<br>                &lt;/all&gt;<br>            &lt;/httpConfiguration&gt;<br>        &lt;/configuration&gt;<br>    &lt;/server&gt;<br>&lt;/servers&gt;</pre><p>The id in settings.xml needs to match other configurations provided for uploading packages and installing dependencies.</p><h3>Upload a Maven package</h3><p>Maven artifacts can be added to the private repository using mvn deploy (or by uploading files manually).</p><p>To deploy using the mvn client users need to add the necessary configuration to the project pom.xml file.</p><pre>&lt;!-- Add the repository and snapshotRepository configuration to pom.xml --&gt;</pre><pre>&lt;distributionManagement&gt;<br>    &lt;repository&gt;<br>       &lt;id&gt;{MAVEN-REGISTRY}&lt;/id&gt;<br>       &lt;url&gt;https://{WORKSPACE}.bytesafe.dev/maven/{REGISTRY}/&lt;/url&gt;<br>    &lt;/repository&gt;<br>    &lt;snapshotRepository&gt;<br>       &lt;id&gt;{MAVEN-REGISTRY}&lt;/id<br>       &lt;url&gt;https://{WORKSPACE}.bytesafe.dev/maven/{REGISTRY}/&lt;/url&gt;<br>    &lt;/snapshotRepository&gt;<br>&lt;/distributionManagement&gt;</pre><p>Users can choose to deploy snapshots and release versions to either the same or different registries.</p><p>With your Maven project configured you can deploy artifacts to your private registry either manually or as part of your CI/CD chain.</p><pre># Deploy artifacts to Bytesafe using Maven </pre><pre>$ mvn clean deploy</pre><p>As soon as the process has been completed, the artifact will be available and accessible.</p><h3>Resolving Maven project dependencies</h3><p>A major part of building a Maven project is resolving any dependencies specified for the project. Any &lt;dependency&gt; specified in the pom.xml file will be fetched when building the project.</p><p>When using private repositories from <a href="https://bytesafe.dev/">Bytesafe</a>, public dependencies will be proxied, pulling any required (and allowed) version into your private Maven repository. Using public repositories like Maven Central as an <a href="https://docs.bytesafe.dev/upstreams/configuring-upstreams/">upstream</a> makes sure you can access your organization’s required open-source dependencies — while maintaining security and control.</p><p>To make sure security features are not bypassed for individual projects, it’s recommended to use a mirror configuration to set the private Maven repository as the general package source.</p><pre>&lt;!-- Mirror configuration in settings.xml --&gt;</pre><pre>&lt;mirrors&gt;<br>   &lt;mirror&gt;<br>       &lt;id&gt;{MAVEN-REGISTRY}&lt;/id&gt;<br>       &lt;mirrorOf&gt;*&lt;/mirrorOf&gt;<br>       &lt;url&gt;https://{WORKSPACE}.bytesafe.dev/maven/{REGISTRY}/&lt;/url&gt;<br>   &lt;/mirror&gt;<br>&lt;/mirrors&gt;</pre><p>With project dependencies specified in the pom.xml file, you can install dependencies using regular Maven commands like mvn install or mvn verify.</p><pre># Install Maven dependencies from Bytesafe </pre><pre>$ mvn clean install</pre><h4>Installing SNAPSHOT versions</h4><p>To install snapshot versions ( X.-SNAPSHOT) with Maven, users are required to explicitly specify the use of a snapshot repository. This is because there is no default snapshot repository associated with Maven.</p><p>This can be set either per project in the pom.xml file or project agnostic as part of a user&#39;s profile. See the <a href="https://docs.bytesafe.dev/package-managers/maven/#installing-snapshot-versions">Bytesafe documentation</a> or the official <a href="https://maven.apache.org/guides/getting-started/index.html">Maven docs</a> for more details.</p><h3>Using Gradle with your Maven repository</h3><p>Gradle is a popular alternative build automation tool for JVM-based projects that work with Maven compatible repositories.</p><p>To resolve project dependencies from the private Maven repository, the repository needs to be declared in the build.gradle file.</p><pre>// repository configuration in build.gradle<br><br>repositories {<br>   maven {<br>      name = &#39;bytesafe&#39;<br>      url &#39;https://{WORKSPACE}.bytesafe.dev/maven/{REGISTRY}/&#39;<br>      credentials {<br>         username = &#39;bytesafe&#39;<br>         password = &#39;{ACCESS-TOKEN}&#39;<br>      }<br>   }<br>}<br><br>// specify project dependencies<br><br>dependencies {<br>   implementation &#39;{GROUP_ID}:{ARTIFACT_ID}:{VERSION}&#39;<br>}</pre><blockquote><strong><em>Note:</em></strong><em> Users should consider storing credentials in </em><em>~/.gradle/gradle.properties file in-place of </em><em>build.gradle to avoid unintended distribution of credentials.</em></blockquote><p>To publish a package using Gradle, enable the maven-publish plugin and specify the target publishing repository in the build.gradle file.</p><pre>// enable the maven-publish plugin</pre><pre>plugins {<br>   id &#39;maven-publish&#39;<br>}<br><br>publishing {<br>   publications {<br>      maven(MavenPublication) {<br>   }<br>}<br><br>repositories {<br>   maven {<br>      name = &#39;bytesafe&#39;<br>      url = &#39;https://{WORKSPACE}.bytesafe.dev/maven/{REGISTRY}/&#39;<br>      credentials {<br>        username = &#39;bytesafe&#39;<br>        password = &#39;{ACCESS-TOKEN}&#39;<br>      }<br>   }<br>}</pre><p>With these quick additions to your Gradle project, you should be able to both build and deploy your own project using a private Maven repository as well as install any required dependencies.</p><h3>Want to know more about Bytesafe’s Firewall for dependencies?</h3><p>Secure your supply chain with private registries compatible with package managers like npm, maven, and NuGet. Refer to the Bytesafe documentation on <a href="https://docs.bytesafe.dev/package-managers/">package managers</a> for more in-depth information and guides.</p><p>Enforce your security policies and <a href="https://bytesafe.dev/posts/using-quarantine-dependency-firewall/">automatically quarantine</a> unwanted dependencies. Avoid <a href="https://bytesafe.dev/posts/safety-delay-protect-from-compromised-versions/">compromised new versions</a> with a set delay before newly published versions are allowed in your organization.</p><p>Want to try it for yourself? <a href="https://login.bytesafe.dev/signup">Sign up</a> for Bytesafe and get started today — no strings attached.</p><p><em>Originally published at </em><a href="https://bytesafe.dev/posts/secure-java-dependencies-with-maven-repositories/">bytesafe.dev</a> <em>on December 20th, 2021.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1760176710a4" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/host-secure-your-java-dependencies-in-5-minutes-with-a-private-maven-repository-1760176710a4">Host &amp; Secure your Java dependencies in 5 minutes with a Private Maven repository</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Want resilience against compromised packages? Add delay before trusting new versions]]></title>
            <link>https://andreas-sommarstrom.medium.com/want-resilience-against-compromised-packages-add-delay-before-trusting-new-versions-1fd866efe23e?source=rss-2d1f31c556c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fd866efe23e</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[dependencies]]></category>
            <category><![CDATA[supply-chain]]></category>
            <dc:creator><![CDATA[Andreas Sommarström]]></dc:creator>
            <pubDate>Thu, 16 Dec 2021 15:33:15 GMT</pubDate>
            <atom:updated>2022-04-26T11:36:53.614Z</atom:updated>
            <content:encoded><![CDATA[<h3>Protect against compromised packages with a safety delay before trusting new versions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*hLbr1X1xS5Lu5qitlqvZRw.png" /></figure><p>It’s common to regularly pull the latest versions of packages from public upstreams — without review or regard for version maturity. And in most cases as a consequence of a build rather than from any real intention to actually make updates to the dependency composition.</p><p>This is most apparent in ecosystems like npm, where the dependency tree with ranges of compatible versions turn each npm install into a unique fetch of what is the &quot;latest and greatest&quot; at that time.</p><p><strong>But with popular packages often being targets for attacks there is every reason to be cautious. Perhaps a little friction is desirable for the sake of security?</strong></p><p>To prevent malicious attacks like <a href="https://bytesafe.dev/posts/case-study-protecting-every-part-of-the-organization-from-malicious-threats/">ua-parser-js, coa &amp; rc</a> from happening in your organization, what if newly released dependencies weren’t allowed to be used immediately? With new packages only permitted for your developers or CI/CD after a set safety period.</p><p><strong>Good news!</strong> Easily achievable with the Dependency Firewall in <a href="https://bytesafe.dev/">Bytesafe private registries</a>. Here’s how.</p><h3>Don’t allow packages until a set safety delay has passed</h3><p>The <a href="https://docs.bytesafe.dev/policies/delay-upstream/">Delay Upstream</a> policy allows for a custom delay before new versions are allowed in your private registries.</p><p>Until the set delay (in days) has passed, new versions are made unavailable to your organization. With other recent and allowed versions automatically selected for you — to not break your builds.</p><p>By giving millions of open source users in ecosystems like npm and maven a chance to evaluate new releases, you could prevent critical vulnerabilities and malicious packages. With the right balance you could save your organization from being compromised.</p><h3>Example of how it works</h3><p>A new version of a dependency, 1.3.0, is released to a public registry like npmjs or maven central. For as long as current time &lt; publish time + safety delay the new version does not qualify and will be prevented from being used by your organization.</p><p>Actions by developers or automated systems to fetch the project’s dependencies will instead receive the most recent allowed version 1.2.3 from Bytesafe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/0*X8NgS5kwsWhObs2a.png" /></figure><p>When current time &gt;= publish time + safety delay the new version 1.3.0 will be allowed in your organization and any subsequent fetches will receive the new version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/0*AZQI9idbaQV15ZZv.png" /></figure><h3>Customize the safety delay to match your needs</h3><p>What the desired “maturity since release” is, differs between organizations. To accommodate, the delay in Bytesafe is completely customizable per registry in your workspace up to a maximum of 90 days.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*Emrco75JLLgzJq2f.png" /></figure><p>Your organization can find the right balance between delay (security) and access to new functionality.<br>Adjust it to your needs per ecosystem and enforce a delay of 3 weeks for <a href="https://bytesafe.dev/npm/">npm</a> while using 2 months for <a href="https://bytesafe.dev/maven/">maven</a> — if it’s right for you.</p><h3>Patch versions intentionally</h3><p>If the need arises to add a specific new security patch or functionality, consider using a separate patch registry to manually (and intentionally) add the required versions. Complete control, while keeping automated environments safe and secure!</p><h3>Looking to secure your supply chain?</h3><p>With the <a href="https://docs.bytesafe.dev/policies/delay-upstream/">Delay Upstream</a> policy we want to offer the option to balance flexibility with security, especially for automated environments and decentralized developer organizations.</p><p>In addition, organizations should make it a habit to review and make conscious decisions on the dependencies they are using for a <a href="https://bytesafe.dev/posts/preventing-supply-chain-attacks/">secure supply chain</a>.</p><p>Want to try delay upstreams for yourself? Sign up for <a href="https://bytesafe.dev/">Bytesafe</a> and start for free today.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fd866efe23e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Avoid the (npm) dependency trap]]></title>
            <link>https://andreas-sommarstrom.medium.com/avoid-the-npm-dependency-trap-lessons-learned-from-ua-parser-687b03f6898c?source=rss-2d1f31c556c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/687b03f6898c</guid>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[dependencies]]></category>
            <dc:creator><![CDATA[Andreas Sommarström]]></dc:creator>
            <pubDate>Mon, 01 Nov 2021 09:20:06 GMT</pubDate>
            <atom:updated>2021-11-25T08:25:58.625Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*7I1lhEzbiIma304qePC61w.png" /></figure><h3>How to avoid the [npm] dependency trap</h3><p>With the dust settling after the UA-parser-js, coa and rc incidents, it’s a perfect opportunity to take some time and see what we can learn from it. With some small changes to how you view and work with dependencies, you can take back control — instead of letting the dependencies control and overwhelm you.</p><p>The UA-parser security issue highlights <em>two major things</em> for the npm ecosystem:</p><ul><li><strong>The dependency tree comes with security risks.</strong> Your direct dependencies might not be malicious, but your dependencies of direct dependencies may be targeted. These transitive dependencies often range in hundreds and are large weak points.</li><li><strong>Organizations need to expand the scope of security</strong> and protect more than the CI/CD. Developer environments are often more numerous and more difficult to control, making it a more probable target to be compromised by malicious packages.</li></ul><p>In these ransomware times, it’s more important than ever to protect your whole organization — controlling what packages are allowed in your environments.</p><p><strong><em>The UA-parser-js incident in short</em></strong> <em>JavaScript library ua-parser-js sparked vigorous security activity, as the package was hijacked and three malicious versions were published to the public npm registry. Once again highlighting the need for more security focus in the JavaScript (and other) ecosystems.</em></p><p><em>The library, used to detect browser and user data, has close to 8M weekly downloads by developers around the world and is used as a dependency by 1200+ other packages in the public npm registry.</em></p><p><em>See the </em><a href="https://github.com/advisories/GHSA-pjwm-rvh2-c87w/"><em>security advisory</em></a><em> for more details.</em></p><p><strong><em>Update:</em></strong> <strong><em>Malicious versions of packages coa and rc</em></strong> <em>published on 2021–11–04. Same malware and pattern of attack (and indicating same hijacker), targeting popular support libraries. Malicious versions of both packages later unpublished by npm.</em></p><h3>Dependency tree and levels of dependencies</h3><blockquote>Joe, the junior developer, helps his team with application testing over the course of the weekend. His environment is clean, so he diligently installs the required dependencies for the application using npm install.</blockquote><blockquote>The app only has a few direct dependencies, but with all the transitive dependencies he ends up adding over 700 dependencies. Unfortunately for Joe and his company, it’s already too late as he unknowingly installed a trojan into his environment…</blockquote><p><strong>Installing npm dependencies with package managers is easy</strong> — and we shouldn’t kid ourselves and think that everyone is knowledgeable and informed on potential issues. It’s easy for things to start going wrong with the amount of dependencies and with packages allowed to execute arbitrary scripts as part of the install process.</p><p>And malicious packages are a big threat for your development environment where potential user data, passwords and sensitive information is stored and therefore can be stolen by hackers.</p><h3>Getting compromised without even knowing it</h3><p>Let’s use the <strong>ua-parser-js</strong> attack as an example. During the incident any user installing a package with a dependency resolution like ua-parser-js: ^0.7.xx would have gotten a malicious version (0.7.29). The dependency resolution tells us to fetch the latest 0.7 patch version - unless remediated by factors like locked dependency versions.</p><p><strong>So who was affected?</strong> Projects depending directly on ua-parser-js were obviously at risk. But in the typical case the compromised dependency was added as a transitive dependency (dependency of a dependency).<br>Leading to users working with popular libraries and frameworks like react and angular reporting inclusion of the compromised library.</p><p>With transitive dependencies, the number of packages your projects depend on increases dramatically. To the point where it quickly becomes impossible to fully grasp what and how many dependencies your team uses.</p><pre># Example of dependency tree with ua-parser-js included as a transitive dependency. <br># &#39;npm ls&#39; is used to identify the path for a specific dependency</pre><pre>$ npm ls ua-parser-js<br>    yourproject@1.0.0<br>      react@15.7.0<br>       └─┬ fbjs@0.8.18<br>         └── ua-parser-js@0.7.30</pre><pre># Excerpt from fbjs@0.8.18 where ua-parser-js is included as a dependency<br>    &quot;dependencies&quot;: {<br>        ...<br>        &quot;ua-parser-js&quot;: &quot;^0.7.18&quot;<br>        },</pre><pre># ua-parser-js: ^0.7.18 would resolve to the latest 0.7.x version. Installing a compromised version with malware during the time of the incident.</pre><p>In the aftermath after ua-parser-js the biggest issue wasn’t figuring out if your applications used ua-parser, instead it was trying to figure out if you were exposed — in any environment, in any way, across hundreds of developers. A task a lot of companies worked vigorously with, as they lacked proper control over packages that enter their environment.</p><h3>How to avoid the trap? Control instead of being controlled</h3><p>Avoiding similar issues in the future should be a priority — and any investment into proper protection would save time and money in the long run.</p><p>So, the million dollar question — <strong>How do we avoid this in the future?</strong><br>We can mitigate most of the issues by inserting control over dependencies and the patch management process.</p><ul><li><strong>Avoid unintended dependency version changes</strong></li><li><strong>Use a single source of truth for dependencies</strong></li></ul><h3>Locking dependency versions</h3><p>You might be thinking, discussions about using lock-files again? Shouldn’t everyone be aware of and use them by now? And I agree, everyone should use them — but they are not.</p><p>Dependency versions should be updated with intention and not as a side effect. Having consecutive npm install yield slightly different and non-deterministic results is not desired in neither CI/CD nor dev environments.</p><p>Organizations should put in place a process that updates, commits and reviews project lock-files and makes sure every subsequent installation (and user) uses the files.</p><p>Using dependency ranges, instead of pinning exact dependency versions, grants flexibility for the ecosystem — but comes with inherent security risks. Using lock-files (package-lock &amp; yarn.lock) together with npm ci for complete and deterministic installations introduces the <strong>necessary friction</strong> that make updating dependency versions a controlled process.</p><h3>Single source — The dependency firewall</h3><p>Depending directly on public registries and countless GitHub repositories, instead of using a single package source, quickly makes control over the flow of dependencies an impossible task.</p><p>With multiple different sources, how are you going to make sure dependencies comply with your business policies, that they are safe and contain approved licenses?</p><p>The solution: a single hub like <a href="https://bytesafe.dev/">Bytesafe</a> to enforce rules and monitor the flow of dependencies — for every developer, tester and build system.</p><p>To make sure everyone is using the same registry source and the intended versions, projects should include a .npmrc config file and package-lock.json or yarn.lock files that define what registry to use.</p><pre># Example .npmrc config setting the default registry to be used by npm clients</pre><pre>registry=https://workspace.bytesafe.dev/r/example-registry/</pre><p><strong>Keep unwanted dependencies out of your organization. Setup a firewall for your dependencies with </strong><a href="https://bytesafe.dev/"><strong>Bytesafe</strong></a><strong>!</strong></p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=687b03f6898c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why you should manage open source dependencies like treasured resources]]></title>
            <link>https://andreas-sommarstrom.medium.com/why-you-should-manage-open-source-dependencies-like-treasured-resources-3d0770573b1?source=rss-2d1f31c556c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d0770573b1</guid>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[devsecops]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[devtools]]></category>
            <dc:creator><![CDATA[Andreas Sommarström]]></dc:creator>
            <pubDate>Mon, 06 Sep 2021 18:21:03 GMT</pubDate>
            <atom:updated>2021-09-06T18:21:03.529Z</atom:updated>
            <content:encoded><![CDATA[<h4>And not simply take them for granted</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*mb8rvMjQbMKktqo2wmbt7Q.png" /></figure><p><em>Open source software (OSS) gives access to a never-ending amount of external development resources. Developing any application, it is simply more efficient to reuse building blocks from others than having to write everything yourself — a necessity for most organisations.</em></p><p><em>Businesses should see the open source they depend on as a valuable resource — that requires management.</em></p><p>Using OSS to build applications allows access to additional developer resources and expertise that wouldn’t otherwise be available.</p><p>The downside — you have no direct influence over the persons behind the component or their actions. Nor do you have any guarantee that every team member is using identical, safe components — without controls in place.</p><p>For internal development resources the norm is to spend time and money hiring the best candidates and continuously invest in their skills and performance.</p><p><strong>Businesses need to echo some of that effort spent finding the right in-house talent into safe use of open source — instead of taking it for granted.</strong></p><h3>Open source in short</h3><p>If you’re not working with software development or open source in your day-to-day work, then perhaps the analogy in the title is not self-explanatory. Not to worry, let’s walk through it.</p><p>Today there is no need to start from scratch every time you are to deliver a feature. There are millions of already finished components ready to be used — and they are only a few letters on the keyboard away from being nested in your application and inside your environments.</p><p>What makes something open source is that the source code for all these components is freely available to everyone and anyone, to view, duplicate, work on etc. That means that as long as you adhere to licenses of components, you can use them in your applications to serve your needs.</p><p>And open source software has proven to be an explosive engine for business growth. And it’s everywhere. For ecosystems like JavaScript / npm the figures speak for themselves:</p><ul><li>99% of projects use open source components to some extent.</li><li>An astonishing 70% of all code used to run applications are open source.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/0*dQFcFlM4C8mB9dvM.png" /></figure><h3>So massive upside — what’s the downside?</h3><p>When your application utilize external dependencies you’ll depend on developers who you can exert no direct control over. Without control, how do you know whether the open source components in your codebase are being maintained and adhere to your security guidelines?</p><p><em>Core components of your business are probably relying on components that your dev team has never reviewed or seen the insides of.</em><br>Let that sink in. Eye opening, isn’t it?</p><p>And to be clear, open source is a positive thing. We wholeheartedly support it and use it every day in our own apps. But like most things in life it needs some safeguards to make sure everyone is playing by the rules.</p><blockquote><strong><em>Using a particular open source component extensively?</em></strong><em> Consider supporting it! Sponsor, buy the developers some coffee or spend some development time on improving it.</em></blockquote><h3>Manage the open source you use — by inserting control into your supply chain</h3><p>Not everyone can be an expert — and fortunately you don’t have to be. Committing to safe use of open source can be as simple as supporting the right process and tools for your organisation. Tooling that:</p><ol><li><strong>Keeps track of the open source software used</strong></li><li><strong>Identifies for security threats — and keeps potential issues out</strong></li><li><strong>Highlights issues early- for easier and more cost-effective remediation</strong></li></ol><p><a href="https://bytesafe.dev/">Bytesafe</a> allows you to combine your team’s need for package management of JavaScript open source packages with security. Using Bytesafe, developers can access public open source dependencies or private proprietary components for your applications, securely. Mitigating risks for your business.</p><p>Bytesafe identifies all the components your team is using and keeps track of them for you. Your supply chain is kept secure as part of the firewall where <a href="https://bytesafe.dev/posts/using-quarantine-dependency-firewall/">threats are automatically quarantined</a>. And all <a href="https://bytesafe.dev/posts/using-issue-tracking/">issues are highlighted for you</a> — accessible to all team members.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d0770573b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to prevent Dependency Confusion in your JavaScript supply chain]]></title>
            <link>https://andreas-sommarstrom.medium.com/how-to-prevent-dependency-confusion-in-your-javascript-supply-chain-64434b7f8c96?source=rss-2d1f31c556c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/64434b7f8c96</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[dependencies]]></category>
            <category><![CDATA[supply-chain]]></category>
            <category><![CDATA[npm]]></category>
            <dc:creator><![CDATA[Andreas Sommarström]]></dc:creator>
            <pubDate>Fri, 21 May 2021 08:05:36 GMT</pubDate>
            <atom:updated>2021-09-10T10:35:33.262Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*-nHLBojoM2axAFDzxqyMwg.png" /></figure><p><strong>Dependency confusion</strong> occurs when a system or user is tricked into fetching a package version from a public registry, instead of the intended <strong>trusted</strong> package with the <strong>same</strong> <strong>name</strong> from your private registry.</p><p>Like similar supply chain attacks it’s all about injecting non-intended packages into a vulnerable supply chain, where malicious code can be executed on installation. A critical security threat for your supply chain if left uncontrolled. And a problem that potentially could go unnoticed in automated environments like CI/CD pipelines.</p><p>I’ve previously <a href="https://bytesafe.dev/posts/avoiding-dependency-confusion/">written</a> on the topic with focus on how to use secure package management to improve control of the software supply chain.</p><p>This post focuses instead on a solution that <strong>automatically protects your supply chain against dependency confusion</strong>. A scalable solution that is safe by default and prevents internal packages from being replaced by packages from external sources, without requiring complex configurations.</p><h3>How to automatically protect against dependency confusion</h3><p>Enforcing this protection from dependency confusion is based on using <a href="https://bytesafe.dev/">Bytesafe</a> registries for the private and public npm packages you depend on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/0*7Qz2pYFPdiprDiuP.png" /><figcaption>Bytesafe offers fully managed and private npm registries that allow users to better control their supply chain and secure the private and public packages they depend on.</figcaption></figure><p>With Bytesafe any package version marked as internal, either automatically or manually, will be protected from dependency confusion.</p><p><strong>The solution in short:</strong></p><ul><li><em>Package versions published, pushed or uploaded to an internal registry will automatically be flagged as internal</em></li><li><em>Fetching new versions of internal packages from upstream sources will only consider upstreams with internal versions of the same package</em></li></ul><p>It’s as simple as that.</p><p>Package versions added directly by users are automatically marked as <strong>internal</strong>, making sure internal packages are not exposed by mistake.</p><p>The best part: all the complex logic on how to safely resolve dependencies is handled by Bytesafe, instead of being pushed on to our users.</p><p>Packages <em>without the internal flag</em> will function as they always have, with full access to public upstreams.</p><p>Users can continue to use registries for both public and private packages, enjoying the benefits of a single source of truth for all package dependencies. While simultaneously being fully protected from dependency confusion.</p><h4>Example: Publish internal packages to a private registry</h4><p>Publishing internal packages to a private registry allows them to be shared and available for other team members and systems.</p><pre>$ npm --registry &#39;https://workspace.bytesafe.dev/r/your-internal-registry/&#39; publish</pre><pre>...</pre><pre>+ your-internal-package@4.5.6</pre><p>With the target registry flagged as <em>internal</em> the version will automatically be flagged <em>internal</em> as well. Preventing it from being substituted by package versions from untrusted external sources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/0*yiWvORnGDY6ivyZw.png" /></figure><h3>Protection during dependency resolution (npm install)</h3><p>The core protection of internal packages is evident when resolving dependencies from upstream. This is typically the case when using npm install to install dependencies for a project and npm attempts to fetch all available versions.</p><p>Any attempt to fetch new versions of internal packages will only use upstreams that contain other internal versions of the packages. All other sources will be ignored for the purpose of this action.</p><p>Users can securely install any internal version from their registries, without ever having to worry about the possibility of the package being replaced with a malicious package from any external registry. A protection that scales to all users and systems.</p><h4>Example: Using a Bytesafe private registry together with registry.npmjs.org as an upstream for public packages</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/0*DJh6oKsMOIOoCFY2.png" /></figure><ul><li>Package published to the private registry will be flagged internal</li><li>Install of internal package by other users / systems will never fetch versions from registry.npmjs.org as it does not contain internal versions</li><li>Installing any public package will work as normal, with registry.npmjs.org as a valid upstream</li></ul><h3>Getting started — How to protect your supply chain</h3><p>Any new Bytesafe workspaces and registries come with protection from dependency confusion by default — No additional actions required.</p><ol><li>Create your own <a href="https://login.bytesafe.dev/signup">Bytesafe Workspace</a></li><li>Publish your internal packages to your private registry. They will automatically be marked internal.</li><li>Install/add your other public dependencies. All dependencies are continuously monitored for security issues.</li></ol><p>With both public and private dependencies now in one single source of truth, you can distribute this secure source to all team members and systems.</p><p>With Bytesafe you can create as many private registries as you require to cover all teams and scenarios, and all of them are protected by default. Making it a solution that scales across your whole organization.</p><h3>Upstream issues — additional layer of defence against supply chain attacks</h3><p>Bytesafe also detects <a href="https://docs.bytesafe.dev/issues/">upstream configuration issues</a> that could indicate a supply chain attack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*W-w3TZy-LeqlClpv.png" /><figcaption>Package found in multiple upstreams issue in Bytesafe</figcaption></figure><p>Upstream issues are opened when a package version is found in multiple external upstreams, with non-matching contents. Issues trigger notifications, warning you of a potential dependency confusion attack.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64434b7f8c96" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing packages from private npm registry with GitHub Actions]]></title>
            <link>https://andreas-sommarstrom.medium.com/installing-packages-from-private-npm-registry-with-github-actions-61d4f6328a91?source=rss-2d1f31c556c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/61d4f6328a91</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[continuous-deployment]]></category>
            <category><![CDATA[npm]]></category>
            <dc:creator><![CDATA[Andreas Sommarström]]></dc:creator>
            <pubDate>Mon, 15 Feb 2021 10:07:06 GMT</pubDate>
            <atom:updated>2021-11-25T12:28:52.926Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*pQekUTtemSFfhv9Mz6VO0A.png" /></figure><p>If you are using GitHub Actions as the CI/CD service for your build chain, you may be looking for a way to install private npm packages in your builds.</p><p>The solution: configure a custom package source and install your package dependencies from a private npm registry!</p><p>Integrating a private registry with GitHub Actions couldn’t be easier. <br>So let’s look into how we can setup GitHub Actions to install package dependencies in this way.</p><h3>But first: the basics behind using a private registry</h3><p>The default registry when using npm, is the public npm registry. It contains public packages that are available for any developer to pull required packages from.</p><p>But teams often require a separate and private home for their internal packages. Packages that are their own proprietary code, that is never intended to be published to any public registry.<br>But still need to be shared internally, and most importantly used in builds of applications.</p><p>In such cases, organizations can make use of a private registry to hold their packages. A private registry can either be something that is self-hosted or a service provided by a specialized provider.</p><p><a href="https://bytesafe.dev/"><strong>Bytesafe</strong></a><strong> offers private npm registries. Users can:</strong><br>- Host and cache internal packages and public dependencies in a central hub<br>- Manage, control and <a href="https://bytesafe.dev/posts/preventing-supply-chain-attacks/">secure</a> their whole dependency supply chain<br>- Scan package dependencies for security vulnerabilities, block packages that aren’t secure (read our <a href="https://bytesafe.dev/posts/npm-security-best-practices/">security best practices</a> to learn more)<br>- Identify <a href="https://bytesafe.dev/posts/automated-continuous-license-compliance/">open source licenses</a> of packages used in their build chain and scan for unlicensed or problematic license issues</p><p><em>If your team requires a private registry for your CI/CD chain, </em><a href="https://login.bytesafe.dev/signup"><em>signup for Bytesafe</em></a><em>. Our registries are hosted, secure and require minimal setup. Start for Free!</em></p><h3>GitHub Actions</h3><p><a href="https://github.com/features/actions">GitHub Actions</a> is a workflow automation tool provided by GitHub.<br>With the widespread use of its repository tool, it is no surprise that the popularity of its related (and to an extent included) automation tool only continues to rise.</p><p>Users can build, test, and deploy code according to workflows they define and trigger the workflows based on certain events, like the push of code to a GitHub repo.</p><p><em>To get the CI/CD to install dependencies using the private registry, we need to:<br>1. Provide GitHub Actions with custom configuration for the registry to use, as well as a related access token<br>2. Define our Actions workflow for what steps are to be run as part of our build</em></p><h3>Configuring use of private registry</h3><p>Like many similar services, GitHub Actions relies on the <strong>.npmrc</strong> (npm runtime configuration) file to provide custom instructions to be used by its built-in npm cli.</p><p>If no custom configuration is provided, <strong>npm</strong> will default to fetch required package dependencies from the public registry.</p><p>But as our example uses private packages not available in any public npm registry, we will use <strong>.npmrc</strong> to set a custom parameters for:<br>- <strong>registry</strong> (provide an URL for our private registry)<br>- <strong>authToken</strong> (provide the authentication details required to communicate with the private registry)<br>- <strong>always-auth=true</strong> (force authentication details to be sent alongside requests to private registry)</p><p>The <strong>authToken</strong> will be defined as an environment variable, but more on this later.</p><p>For our example we want to pull all packages from the private registry, as such we will override the default, by simply setting a new registry URL to be used for all packages.</p><p>If we want to pull only a subset of packages from a registry, we can make use of <strong>@scope</strong> and only packages matching the <a href="https://docs.npmjs.com/cli/v6/using-npm/scope">scope</a> will be fetched from that registry.</p><h4>Putting together the .npmrc file</h4><p>First step is to provide on the registry URL that should be used. Bytesafe private registries use the following pattern:</p><pre># replace workspace and registry names to get registry URL </pre><pre>registry=<a href="https://workspace.bytesafe.dev/r/example-registry/">https://workspace.bytesafe.dev/r/example-registry/</a></pre><p>Next we need to create an <strong>authToken</strong> to be used with requests to the private registry. Let’s create a fresh token to be used solely for this CI/CD chain:</p><pre><br># Replace example registry URL with the url for the registry of your choice</pre><pre>$ npm — registry &#39;<a href="https://workspace.bytesafe.dev/r/example-registry/">https://workspace.bytesafe.dev/r/example-registry/</a>&#39; token create</pre><p>We add the generated token from the output to GitHub’s built-in secret store (to make sure we do not leak credentials).</p><p>Create a new repository secret called <strong>NPM_TOKEN</strong> and save the created token. For more information on storing of repository secrets, refer to <a href="https://docs.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets">GitHub’s official documentation on the subject</a>.</p><p>We will configure our workflow to use the environment variable <strong>NODE_AUTH_TOKEN</strong>, which in turn links to the <strong>NPM_TOKEN</strong> secret.</p><p>At this point your <strong>.npmrc</strong> file should look something like this:</p><pre><br># Example .npmrc file where all packages are fetched from Bytesafe</pre><pre>registry=<a href="https://workspace.bytesafe.dev/r/example-registry/">https://workspace.bytesafe.dev/r/example-registry/</a><br>//workspace.bytesafe.dev/r/example-registry/:_authToken=${NODE_AUTH_TOKEN}<br>always-auth=true</pre><p>If you are happy with the state of your file, go ahead and push it to the related repository.</p><h4>Alternative: Have GitHub Actions create the .npmrc file for you</h4><p>GitHub Actions can create the <strong>.npmrc</strong> config for you, with the <strong>actions/setup-node@v1</strong> action.</p><p>If you use this approach, enter the same registry URL that you would use in .npmrc and <strong>always-auth: true</strong> when configuring the GitHub Actions workflow <strong>yaml</strong> file.</p><h3>Define the GitHub Actions workflow</h3><p>Now we are ready to define the workflow and what actions should be run on our behalf.</p><p>This is done by creating a <strong>yaml</strong> file that we store in the projects <strong>.github/workflows</strong> directory. The <strong>yaml</strong> file contains the steps we want to run through.</p><p>We use it to tell GitHub Actions: what trigger to use (push), to checkout the code, what parameters to use with node and to install the dependencies as part of our example:</p><pre><br>on: [push]</pre><pre>jobs:<br> build:<br> runs-on: ubuntu-latest<br> steps:<br> — name: checks out code<br> uses: actions/checkout@v2<br> — name: Use Node.js<br> uses: actions/setup-node@v1<br> with:<br> always-auth: true<br> node-version: ‘14.x’<br> registry-url: <a href="https://workspace.bytesafe.dev/r/example-registry/">https://workspace.bytesafe.dev/r/example-registry/</a><br> — name: Install dependencies using a safe clean install<br> run: npm ci — ignore-scripts<br> env:<br> NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}</pre><pre># skip ‘registry-url’ and ‘always-auth: true’ parameters if these are provided by a custom .npmrc file<br></pre><p><strong>Voila!</strong> With that we have now configured a GitHub Actions workflow using packages from a private registry.</p><p>With a setup like this, each time code is pushed to the registry, GitHub Actions will safely install the dependencies using <strong>npm ci</strong> with — <strong>ignore-scripts</strong> flag set.<br>And obviously this is only an example. Users can design the workflow to perform the actions required for their needs.</p><p>After a workflow has been triggered, users can check the status and progress of the job in the <strong>Actions</strong> tab in GitHub.</p><h3>Want to integrate with other cloud platform or CI/CD services?</h3><p>The basic principle of using the .<strong>npmrc</strong> file to provide custom configuration is applicable for many other similar services as well.</p><p>Users that want to integrate Bytesafe with other services can refer to our general <a href="https://docs.bytesafe.dev/use-cases/integrating-services-with-bytesafe/">guide on integrating services with Bytesafe</a> on our docs site for more information.</p><p>And if you need more GitHub Actions specific details to get your build chain up and running, refer to the <a href="https://docs.github.com/en/actions/guides/building-and-testing-nodejs">official GitHub Actions documentation for setting up node.js</a></p><p>Thanks for reading!</p><p><a href="https://login.bytesafe.dev/signup">Need a secure private registry for your packages? S<em>ignup for Bytesafe</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61d4f6328a91" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[npm security issues to know of in 2021]]></title>
            <link>https://andreas-sommarstrom.medium.com/npm-security-issues-to-know-of-in-2021-57505d30fdb4?source=rss-2d1f31c556c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/57505d30fdb4</guid>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[dev-sec]]></category>
            <category><![CDATA[dependency-management]]></category>
            <category><![CDATA[application-security]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Andreas Sommarström]]></dc:creator>
            <pubDate>Mon, 25 Jan 2021 09:53:41 GMT</pubDate>
            <atom:updated>2021-01-25T09:53:41.567Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*Wogeb7b3oTqJFt_gjtVf_g.png" /></figure><p>What security issues were talked about in the npm ecosystem in 2020? Let’s review some key takeaways to carry with us into 2021.</p><p><em>We at </em><a href="https://bytesafe.dev/"><em>Bytesafe</em></a><em> want to raise awareness on topics of npm security and secure management of package dependencies. Knowing is half the battle</em></p><h3>Continued growth = vulnerabilities</h3><p>The 10+ million JavaScript developer community introduced over 500,000 new component releases in 2020, with 1.3+ million packages now available to developers in npm alone. With on average 90,000 npm packages downloaded annually per developer.</p><p>According to <a href="https://software-lab.org/publications/usenixSec2019-npm.pdf">research from the University of Darmstadt</a> published in August 2019 it revealed that a significant percentage (up to 40%) of all npm packages depend on code with at least one publicly known vulnerability.</p><p>Code may be vulnerable either because it contains vulnerabilities, or because it relies on dependencies that contain vulnerabilities. In modern software, 80% or more of most applications’ code comes from dependencies.</p><p>Highly popular packages directly or indirectly influence many other packages (often more than 100,000) and are thus potential targets for injecting malware.</p><p>Npm packages have been the target of many malicious packages, due to the fact that the code can be easily triggered during package installation (unless directly handled e.g. with `<strong> — ignore-scripts</strong>`).</p><p>Together with an ethos of “shared trust” within the open source community, <br>bad actors can prey on developers that don’t consider that their dependencies could potentially contain malicious content (intentionally or not).</p><h3>Teams need to be aware of malicious packages</h3><p>A review of <a href="https://www.npmjs.com/advisories">npm’s publicly available advisory databases</a> easily identifies numerous package security issues created with malicious intent.</p><p>According to <a href="https://octoverse.github.com/">GitHub’s 2020 report into open source security</a>, 17% of vulnerabilities were explicitly malicious (while triggering just 0.2% of security alerts). So although most software vulnerabilities are still mistakes, teams should be aware and guard against malicious packages.</p><p>Well-known and trusted packages could be targeted with a contaminated payload or new packages are created to intentionally introduce security issues, with the assistance of any user that accidentally download it. The goal is typically to steal information, cryptocurrency or hack applications.</p><h3>Typosquatting is a major threat</h3><p>Typosquatting (and the similar combosquatting) aims to get users to inadvertently install malicious packages by naming them in such a way that developers believe they are downloading an official package.</p><p>Attackers know that through human error, developers make typos or won’t invest time in checking code dependencies. The intent is getting their malicious packages pulled into your project (supply chain) and using that to get access to whatever system your project is finally deployed to.</p><p>Most malicious packages in the npm advisory database from 2020 are typosquatting atempts. Examples include the now removed <strong>twilio-npm</strong> package trying to piggy back on the popular package: <a href="https://www.npmjs.com/package/twilio">twilio</a>. <br>More examples can be found in related articles <a href="https://www.zdnet.com/article/malicious-npm-package-opens-backdoors-on-programmers-computers/">here</a> and <a href="https://www.zdnet.com/article/three-npm-packages-found-opening-shells-on-linux-windows-systems/">here</a>.</p><p>More details? See our previous post on <a href="https://bytesafe.dev/posts/typosquatting/">Typosquatting</a>.</p><h3>Security issues in popular libraries can have a huge impact</h3><p>Vulnerabilities were identified in packages like: <a href="https://www.npmjs.com/advisories/1523">Lodash</a>. Although not malicious in its intent, the sheer popularity of the library makes the impact of the identified security issues that much larger.</p><p>Similarly, the previously identified issues with earlier versions of <strong>JQuery </strong>cause similar impact, where its widespread use makes it easy to detect use of vulnerable versions in many public websites still in 2021.</p><h3>Strategies for efficient and secure management of dependencies</h3><p>The security of an application depends not only its own code, but also on how secure the direct and indirect dependencies are. Therefore, it’s important to keep your packages up-to-date and be aware of vulnerabilities.</p><p>Related to this, dev teams in 2021 need to adopt a strategy for how to best keep their dependencies up to date. One that weighs automation vs security aspects. <br>A strategy that keeps teams in control, where dependencies are updated with intention and not as a consequence or afterthought.</p><p>This may include work on topics like specifying dependencies with exact or range versions, automatic patching of dependencies and the general approach and mindset when adding new dependencies to a project.</p><p>—</p><p>Thanks for reading! Much appreciated!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57505d30fdb4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why you should use an npm proxy for your JavaScript]]></title>
            <link>https://andreas-sommarstrom.medium.com/why-you-should-use-an-npm-proxy-for-your-javascript-5fbf3a5c88c6?source=rss-2d1f31c556c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fbf3a5c88c6</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[devsecops]]></category>
            <dc:creator><![CDATA[Andreas Sommarström]]></dc:creator>
            <pubDate>Thu, 30 Apr 2020 08:02:05 GMT</pubDate>
            <atom:updated>2020-04-30T09:09:22.642Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3fSnoAGu24uzC25x" /><figcaption>Photo by <a href="https://unsplash.com/@jesseramirezla?utm_source=medium&amp;utm_medium=referral">jesse ramirez</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This short post talks about how using a <strong>private npm proxy</strong> helps improve control and security when using JavaScript packages in <em>general</em> and <em>npm in particular</em>.</p><ul><li>Want to visualize your package dependencies?</li><li>Enforce security policies?</li><li>Manage your dependency on the public npm registry?</li></ul><p>Read on to see why setting up and using an npm proxy is something you should consider.</p><p><em>Disclaimer: I originally posted an extended version of this article on </em><a href="https://bytesafe.dev/"><em>bytesafe.dev </em></a><em>on April 9, 2020.To read the complete post there with more insights on the benefits of using Bytesafe as your private registry provider, </em><a href="https://bytesafe.dev/posts/npm-proxy/"><em>click here</em></a></p><h3>Why an npm proxy is a good idea</h3><p>Millions of developers use the public npm registry every day and with its &gt;1.3 million packages it is an important asset in the JavaScript ecosystem (recent news that GitHub has acquired npm, Inc only emphazises that).</p><p>But with the convenience of the public npm registry and the development speed all those available open source packages entail, comes downsides for keeping track of and managing all those dependencies.</p><p>Therefore, taking steps to improve <strong>control over dependencies</strong> and overall <strong>security when using npm</strong> is a necessity for any organization that want to manage their code supply chain (and not blindly trust code from external sources).</p><p>And one of the first things that is usually mentioned for improved npm security is the use of an npm proxy.</p><h4>Control over dependencies — How?</h4><p>There are multiple ways an npm proxy enables better dependency control:</p><ul><li><strong>Central registry:</strong> an npm proxy acts as a central registry for all your required package versions. Private and public together, possibly from multiple upstream sources.</li><li><strong>Visualization of dependencies:</strong> With all required packages in one place it enables identification of a potential issues. Additionally the proxy caches your packages, removing the worry that an essential package version will be unpublished in the future.</li><li><strong>Single source:</strong> With all developers using the same proxy registry, all users make use of the same package source and versions. Removing the potential issue of unknowingly building with different versions of a dependency.</li></ul><h4>Improved security — How?</h4><p>Using an npm proxy enables a layer of separation between your organization and the outside JavaScript world.</p><ul><li><strong>Policies: </strong>an npm<strong> </strong>proxy introduces an important layer where you can enforce the security policies your organization require.</li><li><strong>License compliance:</strong> all dependencies in one place to review or scan for problematic licenses</li><li><strong>Security scanning:</strong> review dependencies for known vulnerabilities and security problems</li></ul><h3>Using Bytesafe as a proxy</h3><p>Bytesafe’s hosted private npm registries by default works as an npm proxy. All that is required is a configured upstream to your registry. Enabling the benefits of both an npm proxy and the additional benefits that Bytesafe offers to your workflow (and Bytesafe is available as free account btw).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*-e-JUhHz_OJPmVtCc2wvhg.png" /><figcaption>Example workflow when using a Bytesafe registry as an npm proxy</figcaption></figure><p>When using Bytesafe, developers configure their npm client to interact with the Bytesafe private registry instead of the (default) public registry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*CMsoAjEhURlKlcWxPhWZ_g.png" /><figcaption>Example of using npm client with a Bytesafe registry (use ‘— registry’ flag or change default registry using ‘npm config set registry’)</figcaption></figure><p>With the npm client no longer directly linked to the public registry, it results in the following workflow:</p><blockquote><strong>Developers</strong> publish/install package versions to/from the Bytesafe private registry — no interaction directly with the public registry. No need to change any behavior or usage patterns. Using regular tools and clients.</blockquote><blockquote><strong>Proxy registry</strong> holds all public and private packages and any required dependencies. If a package version is required that is not in the proxy registry it is pulled from upstreams.</blockquote><blockquote><strong>Upstreams</strong> registries provide proxy registry with package versions (when required) and is the target for push of packages from proxy. Upstreams can be either a single registry or multiple registries.</blockquote><h3>Recap</h3><p>Setting up and using a npm proxy is an easy and effective way to keep JavaScript dependencies in check and improve security when using npm. Without impacting or changing the workflow for developers. If your organization wants to stay in control and manage your code supply chain you should setup an npm proxy.</p><p>Bytesafe offers hosted, private, reliable and free private npm registries that helps your organization / team to collaborate on your JavaScript code. In addition Bytesafe offers a growing list of Policies &amp; Plugins that aim to simplify your JavaScript workflow (e.g. Freezing registry states, auto-forwarding package versions to upstreams, security scanning and more)</p><p><em>For more details, visit </em><a href="https://bytesafe.dev/"><em>Bytesafe</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fbf3a5c88c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>