<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vinicius Pereira</title>
    <description>The latest articles on DEV Community by Vinicius Pereira (@nivicius).</description>
    <link>https://dev.to/nivicius</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1681350%2F2e104df1-a450-4a84-be7a-c12dbfbf769c.png</url>
      <title>DEV Community: Vinicius Pereira</title>
      <link>https://dev.to/nivicius</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nivicius"/>
    <language>en</language>
    <item>
      <title>How to Enable CodeQL Analysis in Your GitHub Repository</title>
      <dc:creator>Vinicius Pereira</dc:creator>
      <pubDate>Sun, 18 May 2025 01:28:14 +0000</pubDate>
      <link>https://dev.to/nivicius/how-to-enable-codeql-analysis-in-your-github-repository-5ad3</link>
      <guid>https://dev.to/nivicius/how-to-enable-codeql-analysis-in-your-github-repository-5ad3</guid>
      <description>&lt;h2&gt;
  
  
  What is CodeQL?
&lt;/h2&gt;

&lt;p&gt;CodeQL is GitHub's semantic code analysis engine that lets you discover vulnerabilities in your code before they reach production. It treats code as data, allowing you to query your codebase like a database and find security weaknesses automatically.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Use CodeQL?
&lt;/h2&gt;

&lt;p&gt;Detect Real Vulnerabilities: Find SQL injections, XSS, path traversals, and more&lt;br&gt;
Integrated Security: Runs directly in your GitHub workflow&lt;br&gt;
Multiple Languages: Supports JavaScript, TypeScript, Python, Java, C#, C++, Go, and Ruby&lt;br&gt;
Free for Public Repositories: Complete security analysis at no cost for open-source projects&lt;/p&gt;


&lt;h2&gt;
  
  
  Setting Up CodeQL Analysis in few Steps
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Enable GitHub Actions in Your Repository&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;First, make sure GitHub Actions is enabled:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Navigate to your repository on GitHub&lt;/li&gt;
&lt;li&gt;Click on the "Settings" tab&lt;/li&gt;
&lt;li&gt;Select "Actions" from the sidebar&lt;/li&gt;
&lt;li&gt;Make sure "Allow all actions and reusable workflows" is selected&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;


&lt;h2&gt;
  
  
  First (easier) method
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Go to your repository and click in &lt;code&gt;Security&lt;/code&gt; Tab.
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqc83avbr4s68ltkpjerq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqc83avbr4s68ltkpjerq.png" alt="Select Security tab in repository" width="800" height="42"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  Now click on setup code scanning
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgnpxr68oq7id3ato9rgt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgnpxr68oq7id3ato9rgt.png" alt="Click in setup code scanning" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  Now select &lt;code&gt;Default&lt;/code&gt; option
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpou9r5h9z8y2n9kg7qbt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpou9r5h9z8y2n9kg7qbt.png" alt="Select default option" width="800" height="712"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  After select default you'll see the following prompt
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdg8fifch4yee0yp1u61m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdg8fifch4yee0yp1u61m.png" alt="Configuration prompt" width="490" height="595"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It shows languages that you have in your project and workflows if available too. You can click in &lt;code&gt;edit&lt;/code&gt; to remove languages, workflows, select branchs to run and so forth.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  Now the second way
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Create a CodeQL Workflow File&lt;br&gt;
Create a new file at .github/workflows/codeql-analysis.yml with the following content:&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;CodeQL&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;Analysis"&lt;/span&gt;

&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;main"&lt;/span&gt; &lt;span class="pi"&gt;]&lt;/span&gt;
  &lt;span class="na"&gt;pull_request&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;main"&lt;/span&gt; &lt;span class="pi"&gt;]&lt;/span&gt;
  &lt;span class="na"&gt;schedule&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;cron&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;30&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;0'&lt;/span&gt;  &lt;span class="c1"&gt;# Runs at 1:30 AM UTC every Sunday&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;analyze&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Analyze&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;permissions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;actions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;read&lt;/span&gt;
      &lt;span class="na"&gt;contents&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;read&lt;/span&gt;
      &lt;span class="na"&gt;security-events&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;write&lt;/span&gt;

    &lt;span class="na"&gt;strategy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;fail-fast&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
      &lt;span class="na"&gt;matrix&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;language&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;javascript'&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;python'&lt;/span&gt; &lt;span class="pi"&gt;]&lt;/span&gt;  &lt;span class="c1"&gt;# Modify these languages as needed&lt;/span&gt;
        &lt;span class="c1"&gt;# Available options: 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby'&lt;/span&gt;

    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Checkout repository&lt;/span&gt;
      &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v3&lt;/span&gt;

    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Initialize CodeQL&lt;/span&gt;
      &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github/codeql-action/init@v2&lt;/span&gt;
      &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;languages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ matrix.language }}&lt;/span&gt;

    &lt;span class="c1"&gt;# Autobuild attempts to build any compiled languages&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Autobuild&lt;/span&gt;
      &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github/codeql-action/autobuild@v2&lt;/span&gt;

    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Perform CodeQL Analysis&lt;/span&gt;
      &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github/codeql-action/analyze@v2&lt;/span&gt;
      &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;category&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/language:${{matrix.language}}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Customize for Your Project
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Modify the workflow file based on your needs:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Branches: Change main to your default branch name if different&lt;/li&gt;
&lt;li&gt;Languages: Update the language matrix to include only languages your project uses&lt;/li&gt;
&lt;li&gt;Schedule: Adjust the cron schedule as needed for regular scanning&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Commit and Push Your Changes
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add .github/workflows/codeql-analysis.yml
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Add CodeQL security scanning workflow"&lt;/span&gt;
git push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  View Results in the Security Tab
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;After the workflow runs:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
&lt;li&gt;Go to your repository on GitHub&lt;/li&gt;
&lt;li&gt;Click on the "Security" tab&lt;/li&gt;
&lt;li&gt;Select "Code scanning alerts" from the left sidebar&lt;/li&gt;
&lt;li&gt;Review any security vulnerabilities discovered by CodeQL&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Code with some security alerts&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft7rl9rg1l7tc8mwaak9i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft7rl9rg1l7tc8mwaak9i.png" alt="Example image with security issues" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Advanced Configuration
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Custom Build Steps&lt;br&gt;
If your project requires custom build steps instead of using the autobuild feature:&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Replace the autobuild step with custom commands&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Custom Build Steps&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
    &lt;span class="s"&gt;# Add your custom build commands here&lt;/span&gt;
    &lt;span class="s"&gt;./configure&lt;/span&gt;
    &lt;span class="s"&gt;make bootstrap&lt;/span&gt;
    &lt;span class="s"&gt;make release&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Perform CodeQL Analysis&lt;/span&gt;
  &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github/codeql-action/analyze@v2&lt;/span&gt;
&lt;span class="s"&gt;Adding CodeQL Query Suites&lt;/span&gt;
&lt;span class="na"&gt;You can use custom query suites for specialized analysis&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="na"&gt;yaml- name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Initialize CodeQL&lt;/span&gt;
  &lt;span class="s"&gt;uses&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github/codeql-action/init@v2&lt;/span&gt;
  &lt;span class="s"&gt;with&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;languages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ matrix.language }}&lt;/span&gt;
    &lt;span class="na"&gt;queries&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;security-extended,security-and-quality&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Available query suites include:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;security-extended: Additional queries for security analysis&lt;/code&gt;&lt;br&gt;
&lt;code&gt;security-and-quality: Security queries plus quality and correctness&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Common Issues&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Workflow not running&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check that GitHub Actions is enabled&lt;/li&gt;
&lt;li&gt;Verify branch names match your repository&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Builds failing&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Look at workflow logs to identify build issues&lt;/li&gt;
&lt;li&gt;Consider using custom build steps if autobuild fails&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Memory issues&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For large codebases, you might need to adjust RAM limits:
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Initialize CodeQL&lt;/span&gt;
  &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github/codeql-action/init@v2&lt;/span&gt;
  &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;languages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ matrix.language }}&lt;/span&gt;
    &lt;span class="na"&gt;ram&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;8192'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Run on schedule to catch issues even when code isn't actively being pushed&lt;/li&gt;
&lt;li&gt;Review alerts promptly and address security issues&lt;/li&gt;
&lt;li&gt;Use pull request integration to catch issues before they're merged&lt;/li&gt;
&lt;li&gt;Configure code owners for security alerts to ensure follow-up&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Setting up CodeQL is a powerful step toward securing your codebase. By incorporating it into your GitHub workflow, you create an automated security review process that can catch vulnerabilities before they impact your users.&lt;br&gt;
For more information, check GitHub's &lt;a href="https://docs.github.com/en/code-security/code-scanning/introduction-to-code-scanning/about-code-scanning-with-codeql" rel="noopener noreferrer"&gt;official CodeQL documentation.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have you implemented CodeQL in your projects? Share your experience in the comments below!&lt;/p&gt;

</description>
      <category>github</category>
      <category>codequality</category>
      <category>githubactions</category>
    </item>
    <item>
      <title>Entendendo pacotes e modulos em Go!</title>
      <dc:creator>Vinicius Pereira</dc:creator>
      <pubDate>Fri, 20 Sep 2024 03:24:31 +0000</pubDate>
      <link>https://dev.to/nivicius/entendendo-pacotes-e-modulos-em-go-2k3</link>
      <guid>https://dev.to/nivicius/entendendo-pacotes-e-modulos-em-go-2k3</guid>
      <description>

&lt;h2&gt;
  
  
  Desvendando Pacotes e Módulos em Go: O que eu não entendia no começo
&lt;/h2&gt;

&lt;p&gt;Quando eu comecei a programar em Go, eu já tinha uma boa base em C, que foi minha primeira linguagem de programação. Isso me ajudou bastante, porque o Go tem muita coisa em comum com C — desde a simplicidade até a performance. Menos palavras-chave, menos complexidade, e uma curva de aprendizado mais suave. Mas então veio a parte que me deixou meio perdido: &lt;strong&gt;pacotes, módulos e o tal do &lt;code&gt;go mod&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Eu lembro de pensar: &lt;em&gt;"Eu só quero compilar um programa simples, por que preciso me preocupar com pacotes?"&lt;/em&gt; E os módulos? Parece que eles surgem do nada e todo mundo fala que são essenciais para gerenciar dependências. Mas calma, vou explicar tudo de um jeito simples para quem já programa, mas ainda não pegou o jeito dessas coisas em Go.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pacotes no Go: Dividindo e Organizando o Código
&lt;/h3&gt;

&lt;p&gt;Primeiro, o conceito de pacote no Go é bem parecido com o que você já viu em C. Pense nos pacotes como uma forma de organizar e reutilizar seu código. Em C, quando você separa funções em arquivos &lt;code&gt;.h&lt;/code&gt; e &lt;code&gt;.c&lt;/code&gt;, no Go você faz algo similar, mas com pacotes. Cada pacote agrupa funcionalidades e permite que você importe o que precisa em outras partes do código.&lt;/p&gt;

&lt;p&gt;Por exemplo, ao invés de ter todas as funções jogadas em um único arquivo, você pode dividir em pacotes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, Go!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Aqui, &lt;code&gt;fmt&lt;/code&gt; é um pacote da biblioteca padrão que cuida da formatação de I/O. Ao importar, você acessa as funções dele. E você pode criar seus próprios pacotes da mesma forma, facilitando a manutenção e organização do código.&lt;/p&gt;

&lt;h3&gt;
  
  
  E o tal do &lt;code&gt;go mod&lt;/code&gt;?
&lt;/h3&gt;

&lt;p&gt;Agora, a parte dos módulos. É aqui que a coisa fica interessante. Se pacotes são como as bibliotecas em C, os módulos são como um "super pacote" que gerencia tudo isso. Eles permitem que seu projeto baixe e use pacotes de terceiros sem dor de cabeça, de uma forma organizada e segura.&lt;/p&gt;

&lt;p&gt;O &lt;code&gt;go mod&lt;/code&gt; é o comando que te ajuda a configurar seu projeto para usar esses módulos. Quando você inicia um projeto novo com &lt;code&gt;go mod init&lt;/code&gt;, você está basicamente criando uma configuração que o Go vai usar para gerenciar as dependências. Isso significa que ele vai baixar automaticamente os pacotes que seu projeto precisa (sem ter que baixar na mão, como você faria em C).&lt;/p&gt;

&lt;p&gt;Por exemplo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go mod init meu-projeto
go get github.com/pacote/fantastico
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Com esses comandos, o Go cria o arquivo &lt;code&gt;go.mod&lt;/code&gt;, que guarda as informações das dependências do seu projeto. Depois, quando você rodar &lt;code&gt;go build&lt;/code&gt;, o Go baixa tudo o que precisa para compilar, direto da internet, sem você ter que se preocupar.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resumindo...
&lt;/h3&gt;

&lt;p&gt;Quando você organiza seu código em pacotes e usa módulos para gerenciar dependências, o Go fica muito mais eficiente. No começo, pode parecer confuso (eu também não entendi de cara), mas assim que você pega o jeito, percebe que pacotes e módulos tornam seu código mais escalável e limpo. Tudo flui melhor, principalmente em projetos grandes.&lt;/p&gt;




</description>
      <category>go</category>
      <category>newbie</category>
      <category>backend</category>
      <category>golangsp</category>
    </item>
    <item>
      <title>Shared Library (Dynamic linking) - It's not about libs</title>
      <dc:creator>Vinicius Pereira</dc:creator>
      <pubDate>Thu, 11 Jul 2024 01:10:13 +0000</pubDate>
      <link>https://dev.to/nivicius/shared-library-dynamic-linking-its-not-about-libs-a9m</link>
      <guid>https://dev.to/nivicius/shared-library-dynamic-linking-its-not-about-libs-a9m</guid>
      <description>&lt;h2&gt;
  
  
  This is my first post here so, let's go.
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;Disclaimer&lt;/code&gt;: I won't create expectations with my posts. Everything I share is part of my learning process, which often involves explaining things to others. I found this method to be particularly effective during my time at &lt;a href="https://www.42network.org/" rel="noopener noreferrer"&gt;42 School&lt;/a&gt;. Therefore, I'll be posting about various topics I'm currently learning or have already learned.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  Why this post?
&lt;/h1&gt;

&lt;p&gt;I'm actually doing a challenge for a job vacancy and I was struggling with  &lt;em&gt;&lt;code&gt;shared objects&lt;/code&gt;&lt;/em&gt; and I'm doing it in my home, so I remember who hard are don't have another person near you to ask things even if they don't know the answer, they help you to think and find new ways or they have new ideas or even better, they help you to have new ideas and so forth.&lt;/p&gt;




&lt;h2&gt;
  
  
  First step
&lt;/h2&gt;

&lt;p&gt;This challenge involves creating a shared library in any programming language of my choice.&lt;br&gt;
The library will be tested with a specifically crafted binary file written in &lt;code&gt;C&lt;/code&gt;. My goal is to ensure the library functions as intended based on the provided test outputs.&lt;/p&gt;




&lt;h2&gt;
  
  
  Working on it
&lt;/h2&gt;

&lt;p&gt;During a recent interview, I was presented with a challenge: create a shared library that functions as a &lt;em&gt;CSV processor&lt;/em&gt;. Initially, I opted to develop it in Go. It seemed like a straightforward task...&lt;/p&gt;

&lt;p&gt;While writing the Go code itself wasn't an issue, the real challenge arose in integrating the library with the &lt;code&gt;C&lt;/code&gt; binary. Every attempt resulted in different errors, often related to missing symbols in the generated shared object &lt;em&gt;(.so file)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Fortunately, I eventually found a solution and was able to test the library using the provided binary. However, running the program resulted in a core dump, indicating unexpected behavior.&lt;/p&gt;

&lt;p&gt;To address this issue, I opted to switch to C++. The primary reason was the perceived ease of interfacing shared objects created in &lt;code&gt;C++&lt;/code&gt; with &lt;code&gt;C&lt;/code&gt; binaries. This approach minimized debugging difficulties and eliminated core dumps.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Despite the initial hurdles, I'm still tackling the &lt;code&gt;CSV processor&lt;/code&gt; challenge in &lt;code&gt;C++&lt;/code&gt;. Having a better understanding of shared objects and dynamic linking &lt;del&gt;(thanks to my previous experience with static libraries)&lt;/del&gt; is definitely helpful. However, the initial issues I encountered took a significant amount of time to resolve.&lt;/p&gt;

&lt;p&gt;Cya!&lt;/p&gt;

&lt;p&gt;Some references to learn about &lt;em&gt;static and dynamic&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://mprtmma.medium.com/c-shared-library-dynamic-linking-eps-1-bacf2c95d54f" rel="noopener noreferrer"&gt;Reduce Your Compile Time&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=Slfwk28vhws" rel="noopener noreferrer"&gt;Low level learning video&lt;/a&gt; &lt;del&gt;I love this channel&lt;/del&gt;&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=mUbWcxSb4fw&amp;amp;t=29s" rel="noopener noreferrer"&gt;Introduction and creation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html" rel="noopener noreferrer"&gt;C Programming&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>c</category>
    </item>
  </channel>
</rss>
