<?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 mosmant on Medium]]></title>
        <description><![CDATA[Stories by mosmant on Medium]]></description>
        <link>https://medium.com/@mottnr?source=rss-d66d3fdc6628------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Eql7l5gzKc04a5HR</url>
            <title>Stories by mosmant on Medium</title>
            <link>https://medium.com/@mottnr?source=rss-d66d3fdc6628------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 01:10:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mottnr/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[Nexus Repository v3.69.0 to v3.82.0 Upgrade Guide (Docker-based)]]></title>
            <link>https://medium.com/@mottnr/nexus-repository-v3-69-0-to-v3-82-0-upgrade-guide-docker-based-5982edfbcca6?source=rss-d66d3fdc6628------2</link>
            <guid isPermaLink="false">https://medium.com/p/5982edfbcca6</guid>
            <dc:creator><![CDATA[mosmant]]></dc:creator>
            <pubDate>Thu, 31 Jul 2025 09:24:14 GMT</pubDate>
            <atom:updated>2025-07-31T09:24:14.321Z</atom:updated>
            <content:encoded><![CDATA[<h3>Upgrading to Nexus Repository 3.71.0 and Beyond</h3><p>This guide provides a step-by-step process for safely upgrading Nexus Repository Manager from v3.69.0 to v3.82.0. During this upgrade, you’ll transition from OrientDB to H2 database.</p><h3>Step 1: Update to Nexus v3.70.x</h3><p>First, you need to update Nexus to v3.70.x version. This is a required intermediate step for the OrientDB to H2 transition.</p><pre># Update the image tag in your Docker Compose file<br># Example: sonatype/nexus3:latest-3.70.x</pre><h3>Step 2: Database Backup</h3><h4>2.1 Create Backup Directory</h4><pre>mkdir -p /nexus/nexus-data/backups<br>chown -R 200:200 /nexus/nexus-data/backups<br>chmod -R 755 /nexus/nexus-data/backups</pre><h4>2.2 Backup from Nexus UI</h4><ol><li>Log into the Nexus web interface</li></ol><p>2. Navigate to <strong>System</strong> → <strong>Tasks</strong> menu</p><p>3. Run the <strong>Export databases for backup</strong> task</p><p>4. Backup location path: /nexus-data/backups</p><p>5. Run this task.</p><h4>2.3 Verify Backup Files</h4><pre>ls -al /nexus/nexus-data/backups/<br><br># Check inside the Docker container<br>docker exec -it nexus ls -la /nexus-data/backups/</pre><h3>Step 3: OrientDB to H2 Migration</h3><h4>3.1 Stop Nexus Service</h4><pre>docker compose down</pre><h4>3.2 Download Nexus DB Migrator</h4><p>In case this file becomes obsolete, I want to share download link <a href="https://help.sonatype.com/en/orientdb-downloads.html">Nexus Repository 3.70.x Downloads with OrientDB</a></p><p>We need to download this file to /nexus/nexus-data/backups/</p><pre>wget https://download.sonatype.com/nexus/nxrm3-migrator/nexus-db-migrator-3.70.4-02.jar</pre><blockquote>Migrator version may change</blockquote><h4>3.3 Run Database Migration</h4><blockquote><strong>Important:</strong> Adjust Java parameters according to your system memory.</blockquote><p><strong>Memory Check: </strong>free -h</p><blockquote>Please check your system whether Java is installed. If not, you must install. Nexus works with Java 8 and Java 11 before v3.71 and Java 17 after v3.71. Check your version. This document contains versions 3.69 and 3.70.x. Therefore, Java 8 or Java 11 is installed on the system.</blockquote><p><strong>For 8GB+ RAM:</strong></p><pre>java -Xmx8G -Xms4G -XX:+UseG1GC \<br>  -XX:MaxDirectMemorySize=8192M \<br>  -jar nexus-db-migrator-*.jar \<br>  --migration_type=h2</pre><p><strong>For 4–8GB RAM:</strong></p><pre>java -Xmx6G -Xms2G -XX:+UseG1GC \<br>  -XX:MaxDirectMemorySize=4096M \<br>  -jar nexus-db-migrator-*.jar \<br>  --migration_type=h2</pre><h4>3.4 Prepare H2 Database File</h4><p>Now, we created a new H2 DB file on /nexus-data/backups/ path, but we need to move this file to/nexus-data/db/ path.</p><pre># Move the nexus.mv.db file to nexus-data/db directory<br>mv nexus.mv.db /nexus/nexus-data/db/<br><br># Set file ownership and permissions<br>chown 200:200 /nexus/nexus-data/db/nexus.mv.db<br>chmod 755 /nexus/nexus-data/db/nexus.mv.db</pre><h3>Step 4: Configure Nexus Properties</h3><p>Add the following line to /etc/nexus.properties file</p><pre>echo &quot;nexus.datastore.enabled=true&quot; &gt;&gt; /etc/nexus.properties</pre><h3>Step 5: Restart Nexus</h3><pre>docker compose up -d</pre><h3>Step 6: Verify Configuration</h3><p>1.Log into the Nexus web interface</p><p>2.Navigate to <strong>System</strong> → <strong>System Information</strong></p><p>3.Verify that OrientDB config is set to false</p><p>4.Verify that H2 DB config is <strong>nexus.datastore.enabled</strong> true.</p><h3>Step 7: Final Update to v3.82.0</h3><h4>7.1 Stop the Service</h4><pre>docker compose down</pre><h4>7.2 Update Docker Image</h4><p>Update the image tag in your Docker Compose file:</p><pre>image: sonatype/nexus3:3.82.0 # or for latest image<br>image: sonatype/nexus3 # or<br>image: sonatype/nexus3:latest</pre><h4>7.3 Restart the Service</h4><pre>docker compose up -d</pre><h4>7.4 Version Verification</h4><p>Verify that the version is v3.82.0 in the Nexus UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*xByvuonA2HuicI3nGnDMWA.png" /></figure><h3>Conclusion</h3><p>By following this guide, you can safely upgrade your Nexus Repository Manager from v3.69.0 to v3.82.0 and transition from OrientDB to H2 database. It’s important to follow each step carefully and perform the necessary checks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5982edfbcca6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Risk Score + Critical Vulnerabilities: Our Custom Approach to Securing the CI/CD Pipeline]]></title>
            <link>https://medium.com/@mottnr/risk-score-critical-vulnerabilities-our-custom-approach-to-securing-the-ci-cd-pipeline-f3fbe613e071?source=rss-d66d3fdc6628------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3fbe613e071</guid>
            <dc:creator><![CDATA[mosmant]]></dc:creator>
            <pubDate>Sun, 27 Apr 2025 20:10:01 GMT</pubDate>
            <atom:updated>2025-04-27T20:10:41.491Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mURArYaGCNwJ07yeXIRw-A.png" /></figure><p>In modern DevOps workflows, speed is essential — but not at the cost of security. As part of our CI/CD pipeline hardening efforts, we integrated <strong>OWASP Dependency-Track</strong> to actively monitor component vulnerabilities and enforce strict policies. In this post, I’ll walk you through how we:</p><ul><li>Created custom <strong>security policies</strong> in Dependency-Track.</li><li>Used the <strong>inheritedRiskScore</strong> and <strong>critical severity vulnerabilities</strong> via API.</li><li>And implemented a condition that <strong>breaks the build</strong> if risk thresholds are exceeded.</li></ul><h4>🛡️<strong>Step 1</strong>: Creating a Policy in Dependency-Track</h4><p>Before any automation or scripting happens, you need to define <strong>what your organization considers acceptable risk</strong>.</p><p>In Dependency-Track:</p><ol><li>Go to the <strong>Policy Management </strong>section in the web interface.</li><li>Click <strong>“Create Policy”</strong>.</li></ol><p>Define the following:</p><p><strong>3. Name</strong>: For example, SamplePolicy ,</p><p><strong>4. Violation State</strong>: Fail (Other options are Warn and Inform)</p><p><strong>5. Operator</strong>: You can choose conditions that are All and Any.</p><p>After we create policy general information, we build policy conditions.</p><p><strong>Conditions:</strong> It contains too many options.</p><p><strong>Operator:</strong> It varies according to the condition, for instance, matches or does not match, is or is not, etc.</p><p><strong>Severity</strong>: Choose from <em>Low</em>, <em>Medium</em>, <em>High</em>, or <em>Critical</em>.</p><p>Attach the policy to a specific <strong>project.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_HJrfKef4dU4Bia4Sl-5AQ.png" /></figure><blockquote>At this point, you might notice: there’s no built-in option to evaluate <strong>inheritedRiskScore</strong>. That’s where the API comes in.</blockquote><p>The built-in policy engine of Dependency-Track doesn’t allow checking for inheritedRiskScore. But the good news is: <strong>it’s exposed via API</strong>.</p><p>Here’s how we handled it:</p><p>We wrote a Bash script that:</p><ol><li><strong>Creates or updates the project</strong>, sending the BOM (Bill of Materials).</li><li><strong>Queries the metrics API</strong> to fetch current risk metrics:</li></ol><ul><li>inheritedRiskScore</li><li>Number of critical vulnerabilities</li></ul><p><strong>3. Breaks the pipeline</strong> if conditions are met.</p><p>Sample API Call for Metrics:</p><pre>curl -s -X GET &quot;http://your-dependency-track/api/v1/metrics/project/$PROJECT_ID/current&quot; \<br>     -H &quot;X-Api-Key: $API_KEY&quot;</pre><p>From this response, we parse:</p><pre><br># Get Risk Score<br>risk_response=$(curl -s -X GET &quot;http://your-dependency-track/api/v1/metrics/project/$PROJECT_ID/current&quot; -H &quot;X-Api-Key: $API_KEY&quot;)<br><br>RISK_SCORE=$(echo &quot;$risk_response&quot; | jq -r &#39;.inheritedRiskScore&#39;)<br>HIGH_SEVERITY=$(echo &quot;$risk_response&quot; | jq -r &#39;.high&#39;)<br>CRITICAL_SEVERITY=$(echo &quot;$risk_response&quot; | jq -r &#39;.critical&#39;)</pre><h4>🔒 Step 3: Define Custom Build Breaking Logic</h4><p>Now that we have the actual security posture, it’s time to enforce rules. Our rule is simple:</p><blockquote><em>If the </em><strong><em>inheritedRiskScore is above 30</em></strong><em>, or if there’s </em><strong><em>at least one critical vulnerability</em></strong><em>, break the build.</em></blockquote><p>This is the critical part of our script:</p><pre>if (( $(echo &quot;$RISK_SCORE &gt; 30&quot; | awk &#39;{print ($1 &gt; 30)}&#39;) )) || [[ &quot;$CRITICAL_SEVERITY&quot; -gt 0 ]]; then<br>    echo &quot;❌ Pipeline failed due to high risk score or critical vulnerabilities!&quot;<br>    exit 1<br>else<br>    echo &quot;✅ Risk score is acceptable and there is no critical issues. Proceeding...&quot;<br>fi</pre><p>This gives us full control over what we consider critical severity vulnerabilities and risk score.</p><p>Here’s the logs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*JEwSAUKjPIszm6W53nF4iA.png" /></figure><h3>🔄 Full Flow Summary</h3><p>Here’s what happens in our CI/CD run:</p><ol><li>🔍 <strong>Check if the project exists</strong> on Dependency-Track.</li><li>📦 <strong>Create or update</strong> the project and send the BOM.</li><li>📈 <strong>Fetch project metrics</strong> using the API.</li><li>🚨 <strong>Break the pipeline</strong> if thresholds are exceeded.</li></ol><p>This ensures any deployment with known <strong>critical vulnerabilities</strong> or a dangerously high <strong>risk score</strong> is automatically blocked.</p><h4>🔚 What We Did — In a Nutshell</h4><p>In our CI/CD pipeline, we wanted to automatically enforce security checks based on real project risk.</p><p>Although Dependency-Track offers a built-in policy engine, it doesn’t support conditions based on inheritedRiskScore, which is a key metric for us. Because of this limitation, we implemented a custom control flow using the Dependency-Track API.</p><p>Here’s what we did:</p><ol><li>🧾 We first created and uploaded a <strong>BOM (Bill of Materials)</strong> for our project.</li><li>📊 Using the API, we fetched detailed <strong>risk metrics</strong>, including inheritedRiskScore and the number of critical vulnerabilities. We have already printed it to see it in the logs.</li><li>🛑 Based on those values, we defined our own <strong>condition</strong> to break the build if:(The values here may vary according to your conditions. )</li></ol><ul><li>Risk Score is greater than 30, or</li><li>At least one critical vulnerability exists.</li></ul><p>This approach ensures that only secure and low-risk builds are promoted through our pipeline — even if the built-in policy rules fall short.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3fbe613e071" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NewRelic Integrations for Next.JS Projects]]></title>
            <link>https://medium.com/@mottnr/newrelic-integrations-for-next-js-projects-0b155dac7021?source=rss-d66d3fdc6628------2</link>
            <guid isPermaLink="false">https://medium.com/p/0b155dac7021</guid>
            <dc:creator><![CDATA[mosmant]]></dc:creator>
            <pubDate>Mon, 30 Sep 2024 06:47:04 GMT</pubDate>
            <atom:updated>2024-09-30T06:47:04.918Z</atom:updated>
            <content:encoded><![CDATA[<h4>Step-by-Step Guide</h4><p>One of the most effective ways to monitor performance and catch errors in your Next.js projects is New Relic integration.In this guide, I will explain step by step how to integrate New Relic into your Next.js project and what settings you need to make.I assume that you have a NewRelic account and License Key while preparing this guide.</p><h4>1. Configuring the .env File</h4><p>First you need to define some environment variables so that New Relic can learn about your application.<br>Create an .env file in the root directory of your project and add the following settings:</p><pre># NEWRELIC<br>NEW_RELIC_APP_NAME=MY_FRONTEND_PROJECT<br>NEW_RELIC_LICENSE_KEY=xxxxx<br>NEXT_PUBLIC_ENABLE_NEWRELIC=true</pre><p><strong>Description:</strong></p><p><strong>NEW_RELIC_APP_NAME:</strong> This is the name of your app that will appear on New Relic.<br><strong>NEW_RELIC_LICENCE_KEY:</strong> The licence key for your New Relic account. You can get this from your New Relic account.<br><strong>NEXT_PUBLIC_ENABLE_NEWRELIC:</strong> We set this value to true to make New Relic active in the project.</p><h4>2. Integration with Dockerfile</h4><p>The Dockerfile defines how your application will be built and run.<br>Here’s how you can configure your Dockerfile so that New Relic integrates correctly into your application:</p><pre>WORKDIR /app<br>COPY package.json ./<br>RUN yarn install<br><br>FROM base AS builder<br>WORKDIR /app<br>COPY --from=deps /app/node_modules ./node_modules<br>COPY . .<br>COPY .env .env<br>RUN yarn build:prod<br><br>FROM base AS runner<br>WORKDIR /app<br><br>ENV NODE_ENV=production<br><br>RUN addgroup --system nodejs --gid 1001<br>RUN adduser --system my_frontend_project --uid 1001<br><br>COPY --from=builder /app/public ./public<br>COPY --from=builder /app/package.json ./package.json<br>COPY --from=builder --chown=my_frontend_project:nodejs /app/.next/standalone ./<br>COPY --from=builder --chown=my_frontend_project:nodejs /app/.next/static ./.next/static<br><br>USER my_frontend_project<br><br>ENV PORT 8080<br>ENV NEW_RELIC_APP_NAME=&quot;MY_FRONTEND_PROJECT&quot;<br>ENV NEW_RELIC_LICENSE_KEY=&quot;your_licence_key&quot;<br>ENV NEW_RELIC_LOG=&quot;/app/newrelic_agent.log&quot;<br><br>CMD [&quot;node&quot;, &quot;-r&quot;, &quot;newrelic&quot;, &quot;server.js&quot;]</pre><p><strong>What did we do in this step:</strong></p><p>Some specific steps mean the following</p><p><strong>-r newrelic:</strong> The -r option stands for ‘require’ and allows Node.js to load a specific module at startup. In this case, the newrelic module is loaded.This option ensures that Node.js loads the newrelic module before running server.js. This way, the New Relic agent becomes active immediately at the start of your application and starts monitoring all transactions and performance metrics.</p><p><strong>server.js:</strong> This is the entry file for your application and is the file from which your application will be launched.</p><h4>3. New Relic Configuration: newrelic.js File</h4><p>You need a configuration file to determine how New Relic will monitor your project.</p><p>Create a file called newrelic.js and add the following content:</p><pre>&#39;use strict&#39;;<br><br>exports.config = {<br>  app_name: [process.env.NEXT_PUBLIC_NEW_RELIC_APP_NAME],<br>  license_key: process.env.NEXT_PUBLIC_NEW_RELIC_LICENSE_KEY,<br>  logging: {<br>    level: &#39;info&#39;,<br>  },<br>  allow_all_headers: true,<br>  attributes: {<br>    exclude: [<br>      &#39;request.headers.cookie&#39;,<br>      &#39;request.headers.authorization&#39;,<br>      &#39;request.headers.proxyAuthorization&#39;,<br>      &#39;request.headers.setCookie*&#39;,<br>      &#39;request.headers.x*&#39;,<br>      &#39;response.headers.cookie&#39;,<br>      &#39;response.headers.authorization&#39;,<br>      &#39;response.headers.proxyAuthorization&#39;,<br>      &#39;response.headers.setCookie*&#39;,<br>      &#39;response.headers.x*&#39;,<br>    ],<br>  },<br>};</pre><p><strong>app_name:</strong> The name of your application on New Relic, using the value from the .env file.</p><p><strong>licence_key:</strong> Your New Relic licence key, also from the .env file.</p><p><strong>logging.level:</strong> Determines at which level New Relic will log (info is an ideal choice for production).</p><p><strong>allow_all_headers:</strong> Allows saving all header information.</p><p><strong>attributes.exclude:</strong> Ensures that the specified headers are excluded during monitoring, i.e. guarantees that no confidential information is logged. This can be changed according to your wishes.</p><h3>BONUS:</h3><h4>4. Version Tracking with UpdateNewRelic.sh Script</h4><p>You can create a script to notify New Relic about every deploy operation in your project. Create a file named UpdateNewRelic.sh and fill it with the following content:</p><pre>#!/bin/bash<br><br># ENV VARIABLES<br>PASSWORD=&quot;API-Key: xxxxxx&quot;<br>HEADER=&quot;Content-Type: application/json&quot;<br>NEWRELIC_SERVER=&quot;https://api.newrelic.com/graphql&quot;<br>ENTITY_GUID=&quot;Your_FE_APP_GUID&quot;<br><br>version=$1<br><br>query=&quot;{\&quot;query\&quot;:\&quot;mutation {\n  changeTrackingCreateDeployment(\n    deployment: { version: \\\&quot;$version\\\&quot;, entityGuid: \\\&quot;$ENTITY_GUID\\\&quot; }\n  ) {\n    deploymentId\n    entityGuid\n  }\n}\&quot;, \&quot;variables\&quot;:\&quot;\&quot;}&quot;<br><br>curl $NEWRELIC_SERVER \<br>  -H &quot;${HEADER}&quot; \<br>  -H &quot;${PASSWORD}&quot; \<br>  --data-binary &quot;$query&quot;</pre><h4>What Does This Script Do:</h4><p><strong>version=$1:</strong> When running the script, the version number is given as a parameter and this value is passed to New Relic.</p><ul><li>The curl command sends a GraphQL request to New Relic and saves a new deployment process.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ttzldp0sD6C972z7QwckIQ.png" /></figure><h3><strong>Conclusion:</strong></h3><p>Now your Next.js project is integrated into New Relic. Thanks to this integration, you can instantly monitor the performance, errors and general health of your application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wT2Ogf6y-0BnYCEFNG9u3Q.png" /><figcaption>Summary</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ltDKS6foJ7VCwC2CFJx_1A.png" /><figcaption>Service Map</figcaption></figure><p>At the end of the article, after completing this process, you can start monitoring the metrics of your application in the New Relic interface and make the necessary optimizations.</p><p>By following this integration process, you can better manage the performance of your Next.js project and improve the user experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0b155dac7021" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Code Insights with Sourcegraph Integration]]></title>
            <link>https://medium.com/@mottnr/code-insights-with-sourcegraph-integration-28e8b422ffea?source=rss-d66d3fdc6628------2</link>
            <guid isPermaLink="false">https://medium.com/p/28e8b422ffea</guid>
            <dc:creator><![CDATA[mosmant]]></dc:creator>
            <pubDate>Tue, 27 Aug 2024 11:42:25 GMT</pubDate>
            <atom:updated>2024-08-27T11:42:25.505Z</atom:updated>
            <content:encoded><![CDATA[<p>Sourcegraph is used as a code search and analysis platform. It is especially useful for teams working on large and complex code bases. Its main features are as follows:</p><p><strong>Code Search:</strong> Sourcegraph allows you to perform fast and accurate searches across multiple repositories. You can find a specific variable, function or text in all projects.</p><p><strong>Code Discovery:</strong> In large code bases, it allows you to see dependencies and relationships. You can analyse which files and functions you may affect before making a change.</p><p><strong>Code Review:</strong> In pull request reviews, you can quickly find and review the relevant code.</p><p><strong>Reference and Definition Tracking:</strong> You can easily see where a function or variable is defined and where it is used.</p><p><strong>Integrations:</strong> Sourcegraph can be easily included in your existing workflow by working integrated with platforms such as GitLab, GitHub, Bitbucket.</p><p>In this article, I will talk about narrowing down your code searches with Sourcegraph more effectively, search more precisely, and reach the result more efficiently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*73Uw9gJbucARclTNFoJIug.png" /></figure><p>Let’s get started</p><p>Before I start all this, I need to mention the <strong><em>context:global</em></strong> filter. This filter will search for your code in all repos that your company has access to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q-B0jbwyMQYNQoGGnvIkcA.png" /></figure><p>With the methods and filters I will explain later, we will be able to narrow down , refine and precise our code searches.</p><h3>Exploration Begins</h3><p>We can use 3 methods when doing a code search.</p><h4>1- Literal search</h4><p>Since this is the default search mode, we can make our queries without using quotation marks. The first button on the far right of the search bar must be enabled for Case-sensitive search.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*MHcrsCrgBySZtTeWOayx2g.png" /></figure><p>With this search method we can search variable names, method names, class names, error messages, comments.</p><h4>2- Regular expression</h4><p>This search method, which uses the RE2 syntax structure, is done by switching the Enable Regular Expression button on the right of the search bar to the enable position.</p><p>We can use Regular Expression markers only to find exact word matches or to find what we are looking for.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*CLOPZMJuADe4hh3pDA_nNw.png" /></figure><p>Also, when we search for plain text with regular expression, the spaces between words are evaluated as ‘*’ and it searches by taking (-_;*!’^+%&amp;/) characters or new words in the spaces between words.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*82CfWIPN2v0yu7MZJWi5cA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*_2SBxNcvDAbivDIIj0vUDg.png" /></figure><h4>3- Structural search</h4><p>The structural search button on the right of the search bar that I see useful to specify is enabled and we can start searching in this way.</p><p>This method will help in searching syntactic code patterns such as function calls, arguments, if-else statements, try-ctach statements. It is basically useful for finding multi-line blocks of code or nested or recursive patterns.</p><p>Structural search is different from regular expressions because it takes into account the syntax of the code like balanced brackets or quoted strings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*Up7UDxtJ3S3twbgPCckH8Q.png" /></figure><p>Here 3 points or ellipsis is placeholder syntax.</p><pre>{<br>    try{<br>        var model = await_demandService.GetFirstRecordAsync():<br>        return HealthCheckResult.Healthy(&quot;API can read data.&quot;):<br>    }<br>    catch{<br>        return HealthCheckResult.Unhealthy(&quot;API could not read data&quot;):<br>    }<br>}</pre><h3>Search Context</h3><p>If we often make the same searches or work in a specific scope, always working in the global context can waste our time. Search context can allow us to work in a specific repo or a specific context.<br>For this we can click on context:global. and we can create our own context. if we want we can bring it as default in our user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*ilE1hBNi9M2xkxGdouLavw.png" /></figure><p>Here are my search contexts.</p><p>If you want to create your own search contexts, you should click the <strong>Create search context</strong> button, then you should name it and you can prepare and use your queries either as Search query or JSON configuration. You can use these search contexts you have prepared on the homepage by default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2W_Lfsbt7hVnDdIDDBDoog.png" /></figure><h3>Search Snippets</h3><p>Search snippets are defined in your Sourcegraph settings. Add an entry called search scopes that contains a name and a search query snippet for your snippet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*xYI2mbc0T4jEOe_f_KM95g.png" /></figure><p>You can find and use this snippet at the bottom of the sidebar of the search result page. This will make the Dynamic filters more effective.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*vtibzJ6WbPOGsAIMr6MlMQ.png" /></figure><h3>Dynamic Filters</h3><p>When we do a search, there is a dynamic filter section on the side of the results page where we can narrow down your results and use your own snippets.</p><p>It consists of 2 sections. repo and bracnch-tag. These two sections do not appear on the sidebar at the same time. It may also change according to the search form.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*mAf8cadLtmiOkAtL-w6Duw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*XuwmyvR0g-ZhlCnrdSqS0g.png" /></figure><h3>Basic search code keywords</h3><p>This section documents the search pattern syntax in Sourcegraph. To match file content, you need to specify a search pattern. Search patterns are optional when searching commits, filename, lang, or repository names.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*alFNMpMKAEqx6E6R4V09-w.png" /></figure><h3>Installation and Integration</h3><p>I installed SourceCode as dockerized. The docker-compose file is available at this <a href="https://github.com/sourcegraph/deploy-sourcegraph-docker/blob/master/docker-compose/docker-compose.yaml">link</a>.</p><p>All integrations are made from the same place and as Admin.<br>Admin User avatar &gt; Site Admin &gt; Manage code hosts</p><h4>Gitlab integration</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*DT8FQyRQThZBi7f3szXTDQ.png" /></figure><p>Then we can check our connection with the Test Connection button.</p><h4>Bitbucket integration</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zlS0zMCcx06UTy64MK-SxQ.png" /></figure><p>There is also something I would like to mention here. We need to add our Bitbucket Workspaces to the teams key as Array. Then we can check our connection with the Test Connection button.</p><h3>Bonus content</h3><p>There is now a history button in the searchbar. The history button, which joins us with the latest version, shows us our past searches. In this way, we can easily find the searches we have made before, and our old searches can guide us while making our new searches.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*PKTXV28g0Shm1Sdn0qpDBA.png" /></figure><h3>Conclusion</h3><p>All in all, Sourcegraph is a powerful tool that makes it easy for you to understand, track and manage code. It improves productivity and ensures better code quality, especially in large teams.</p><p>I hope this article was useful. Since the purpose of writing this article is effectively code search, other features of the application are not mentioned. The docs where you can find other features and details of the application are <a href="https://sourcegraph.com/docs/code-search">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28e8b422ffea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Adventure Begins: Managing Linux Servers with Cockpit]]></title>
            <link>https://medium.com/@mottnr/the-adventure-begins-managing-linux-servers-with-cockpit-a9a60b8f3ca1?source=rss-d66d3fdc6628------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9a60b8f3ca1</guid>
            <dc:creator><![CDATA[mosmant]]></dc:creator>
            <pubDate>Thu, 27 Jun 2024 09:13:27 GMT</pubDate>
            <atom:updated>2024-06-27T09:13:27.644Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s fast-changing technology world, system administrators and DevOps engineers are constantly looking for more efficient and user-friendly tools. And this is where the Cockpit comes in. In this article, we will explore how we manage our test environments more effectively with Cockpit. If you are ready, let’s start the adventure!</p><h4>Installation: First Step of the Adventure</h4><p>The first step to start exploring Cockpit is to install it on our system. Assuming we are using Ubuntu, the installation process is quite simple:</p><pre>sudo apt-get update<br>sudo apt-get install cockpit<br>sudo systemctl enable --now cockpit.socket</pre><p>After these steps, we can access the Cockpit UI through our web browser. By typing `<a href="https://[server_IP_address]:9090`"><strong>https://[server_IP_address]:9090</strong>`</a> in our browser, we reach the login screen of Cockpit. Here, we log in with our username and password and step into the world of Cockpit. It&#39;s important to remember the following that username and password are the <strong>SSH username and password</strong> of our Ubuntu machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mRDa4YYHz5izefKW72fsAw.png" /></figure><h4>Interface: A Captain’s Quarters</h4><p>Cockpit’s UI is user-friendly and straightforward. It may feel a bit unfamiliar at first, but you will soon start to feel like the captain of this ship. The main screen offers a dashboard where you can quickly see the status of your server. Critical information such as CPU usage, memory status and disk usage can be seen at first glance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cEcJVKCHrP9PZ9Jgo074aw.png" /></figure><p>As you navigate through the UI, you will notice that there are many different modules in the menu on the left-hand side. These modules allow you to browse system logs, manage services and even run commands from the terminal. All these features make system administration easier and more efficient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2k67w9TOvl0161gJidJ0Mg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mZVPfygP5ZCknrt2VgdVqA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FOfw1sMr7AaqtPKU7JN9Ow.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SSNgklGeWWdZDQKXOLejhg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hSOhGG7mEkCKlYgeAfV0Cw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QFRE7TP5EY9K04njlfsFfw.png" /></figure><h4>Adding New Servers: The Adventure Continues</h4><p>One of the most impressive features of Cockpit is the ability to manage multiple servers through a single UI. Adding a new server is easier than you might expect. Simply go to the “Servers” tab in the interface and click on the “Add Server” button.</p><pre>Cockpit &gt; Servers &gt; Add New Hosts</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JQml-u6uyNAlApfrC441lQ.png" /></figure><p>In this step, you will need to enter the IP address and access information of the server you want to add. With each new server you add, you will understand the power and flexibility of Cockpit even better. Now you can manage all your test environments from a single control panel and quickly identify and solve problems.</p><h4>Conclusion: The Beginning of the Adventure, Not the End</h4><p>Managing our test environments with Cockpit is like going on an adventure. Every new feature and module gives us a better insight. From installation to interface, from adding servers to managing them, every step is almost effortless, which makes this application even more fun to use. Cockpit is not just a tool, but a companion that guides us through system administration. In this article we’ve covered the basics of Cockpit, the user interface and adding new servers, but that’s just the beginning ,what you can do with Cockpit will allow you to have a more manageable environments. Join the adventure and explore the world of Cockpit!</p><h4>BONUS: Tricks and Information</h4><p>Unfortunately, the Dashboard tab of the Cockpit application is not visible on Ubunutu 22.xx and above. You must have Ubuntu 20.xx machines to use this tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p1o9YUTVgN6a5M8LTuXdhw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yhF1ELQLpe_zC0PmstcnqA.png" /></figure><p>Do you recognize port 9090 from somewhere? Then how about using another port? So let’s find a port that might be useful and continue our adventure without any problems. Here are the steps you need to do for this;</p><pre>sudo vi /lib/systemd/system/cockpit.socket or <br>sudo nano /lib/systemd/system/cockpit.socket</pre><p>here is the place in the file where we need to change it;</p><pre>[Socket]<br>ListenStream=9024</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*VPjdhemUvE5yRMsRNDbzPw.png" /></figure><p>I have chosen the port that suits me as 9024, you can choose a more suitable port. In order to see and use the changes, follow the steps below;</p><pre>sudo systemctl daemon-reload<br>sudo systemctl restart cockpit.socket</pre><p>Now we can access our Cockpit UI with `<a href="https://[server_IP_address]:9024`">https://[server_IP_address]:9024`</a> in our browser.</p><p>By following these steps, you can easily change the port on which our Cockpit application runs.</p><p>*** This article is a guide for anyone who wants to explore the possibilities of Cockpit and manage our test environments more efficiently. I hope I have inspired you on this adventurous journey. Happy exploring!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9a60b8f3ca1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>