Analyzer Development Guide · Sec · Development · Help · GitLab (2023)

Analyzers are available as Docker images to run as part of a CI pipeline. This guide describes development and testing practices in analyzers.

common unity

For common behaviors and interfaces, there are a number of common Go modules shared between parsers:

  • thisSeriesThe Go package implements the CLI interface.
  • thisUsualThe project provides several common modules for logging, certificate management, and directory search functionality.
  • thisreportloosereportITo discoverStructure for JSON reports.
  • thisrole modelA new analyzer for project scaffolding.

How to use the analyzer

The analyzer is available as a Docker image. For example, runningSamGripScan your working directory for Docker images:

  1. CDChange to the directory of the source code you want to scan.

  2. joggingDocker login registry.gitlab.comand give username pluspersonaltheWorkThe access token is at leastread the recordfield of application.

  3. Run the Docker image:

    docker run\ - interactive --tty - R M \ - Sound volume "$password":/tmp/applications\ --Surrounding area project directory=/tmp/applications\ -w/tmp/applications\registry.gitlab.com/gitlab-org/security-products/analyzers/semgrep:latest /launch analyser
    (Video) Agile Management - GitLab-Jira Development Panel Integration
  4. The Docker container creates a reference to the attached project directory with the reference filename corresponding to the parser class. For example,Senkocreate a file namedgl-sast-report.json.

Analyst development

To update the analyst:

  1. Modify the Go source code.
  2. Create a new Docker image.
  3. Run the profiler in its test project.
  4. Compare the generated report with the expected one.

Here's how you can create oneanalyst:

construction of the ghat-tanalyst.

For example, to check stealth detection, run the following command:

wget https://gitlab.com/gitlab-org/security-products/ci-templates/-/raw/master/scripts/compare_reports.shsh ./compare_reports.sh sdtest/fixtures/gl-secret-detection-report.jsontest/expect/gl-secret-detection-report.json\| fix it-NP1 test/expect/gl-secret-detection-report.json&&Git commit-M "Expectation Update" test/expect/gl-secret-detection-report.jsonR Mcomparative report.sh

You can also compile the binary for your environment and run it locally, butanalyzesIjoggingIt probably won't work because the runtime dependencies for the parser are missing.

This is based onSpotBugs:

(Video) Salesforce Development with GitLab

build-Theanalyst./search parsertest/Program./parser-transformtest/fixtures/app/spotbugsXml.Xml>./gl-sast-report.json

Executive template

activate the first oneIt is necessary to include the defaultsrole modelin the GitLab CI/CD configuration.

The following independent criteria determine which parser should be run on a project:

  1. Using the SAST templaterule: existsDetermines which parser to run based on the existence of certain files. For example, analyst Brakemanrun me .rbfile and agame file.
  2. Each analyzer performs a customizableappropriate interfacebefore performing the actual analysis. For example:Flawfinder checks C/C++ files.
  3. For some parsers that work on common file extensions, there is checking based on CI/CD variants. For example: Kubernetes events are written in YAML, soto su secundecode onlySCAN_KUBERNETES_MANIFESTS set to true.

Step 1 helps avoid wasted CI/CD time that will be spent running analysts that are not right for the project. However, becausetechnical limitations, cannot be used for large projects. Therefore, step 2 acts as a final check to ensure that mismatched parsers are exited early.

How to test the analyzer

Video tutorial on how to use Dependency Scan Analyzerdownstream pipelineCheck the functionality of the parser using the test project:

Analyzer Development Guide · Sec · Development · Help · GitLab (1)

Try local changes

Test local changes to shared drives (egSeriesthereport) for the parser you can usemodify and replacecommand to loadSeriesUse your local changes instead of issuing the command with a remote tag. For example:

edited for change-replacegitlab.com/gitlab-org/security-products/analyzers/command/v3=/local/path/to/command
(Video) Dev Deletes Entire Production Database, Chaos Ensues

Alternatively, you can update manually viago.moddocument:

Module gitlab.com/gitlab-org/security-products/analyzers/awesome-analyzer/v2Zamijenite gitlab.com/gitlab-org/security-products/analyzers/command/v3 => /path/to/commandrequire (...gitlab.com/gitlab-org/security-products/analyzers/command/v3 v2.19.0)

Test the local changes in Docker

use dockerreplacefrom the insidego.moddocument:

  1. copy contentSeriesChange to the parser directory.cp -r /put/do/naredbe path/do/analizatora/naredbe.
  2. Add a copy of the statement to the analystdocument:command/copy command.
  3. renewreplacestatement to make sure it matches the destinationcopyThe statement in the above step:Replace gitlab.com/gitlab-org/security-products/analyzers/command/v3 => /command

Scenario Analyzer

thisScenario AnalyzerThe repository contains scripts that can be used to interact with most parsers. They allow you to build, run, and debug parsers in a GitLab CI environment and are especially useful for validating parser changes locally.

For more information seeproject readme.

Version control and version process

Analyzers are separate projects that follow their own version control.repairIssue bumps tend to matchUnderageDeprecating versions of key tools (egrobber), which allows us more flexibility in maintenanceUnderageA number of important changes to our scanners. If the packet scanner forces critical changes, you should consider creating a new analyzer in a separate repository.

Analyzers are published as Docker images according to the following scheme:

  • push each timeMr; Mrbranch will overriderubbingimage label
  • any pressure on anyexcellent featurebranch will create a matchexcellent featureimage label
  • Each Git tag creates a counterpartmain.small.patchimage label. Manual tasks allow you to override themMrILatestThe image label indicates thismain.small.patch.

There are two different options for publishing a new Docker analyzer image:

(Video) Breaking down the GitLab SAST Analyzer's Work

  • Manual release procedure
  • Automatic publishing process

Manual release procedure

  1. be sureChangelog.mdThe entry for the new analyst is correct.
  2. Be sure to post the source (usuallyMr; MrtheMrbranch) has a delivery pipeline.
  3. with the optionto organizemenu on the left side of the project window and selectexemptSubmenu.
  4. choosenew product launchOpennew product launchPage.
    1. from the insidetag namedrop-down menu, enter the same versionChangelog.md, For examplev2.4.2, then set the create bookmark option (Create tags v2.4.2here).
    2. from the insidePost titletext box type the same version used above eg.v2.4.2.
    3. from the insiderelease notestext box, copy and paste the comments of the appropriate version into theChangelog.md.
    4. Leave all other settings as default.
    5. choosecreate a release.

After following the above process to create a new release, a new Git tag is created containing ittag namementioned above. This will start a new pipeline with the given tag version and create a new Docker image of the analyzer.

If the analyst usesparser.ymlrole model, and then vaccinated asnew product launchThe above process automatically adds tags and installs a new version of the Docker analyzer image.

If the parser is not usedparser.ymltemplate, you must manually point and deploy a new version of the Docker parser image:

  1. chooseContinuous integration / Continuous integrationmenu on the left side of the project window and selectconveyor beltSubmenu.
  2. For example, a new funnel should be created with the same tags used beforev2.4.2.
  3. Once the pipeline is complete, it will be importedexclusioncondition.
  4. chooseHandmade workplay button on the right side of the window, then selectlabel versionCheck and deploy a new version of the Docker analyzer image.

Use your best judgment to decide when to create a Git tag that will then trigger the release task. If you can't decide, seek the opinion of others.

Automatic publishing process

Before using the auto-publish process, you must do the following:

  1. configurationCREATE_GIT_TAG:真asCI/CD environment variables.
  2. examine, examinevariablein the CI/CD project settings. unless the work is legacyGITLAB_TOKENenvironment variables from the project team, create aproject access tokenIFull access to read/write APIand adjustGITLAB_TOKENasCI/CD environment variablesThis refers to this token.

After the above steps are completed, the automatic publishing process is performed as follows:

  1. The project maintainer merges the MR into the default branch.
  2. the default pipeline starts andenter a git tagJob done.
    • If the latest version is availableChangelog.mdCorresponds to one of the Git tags, the task is not a function.
    • Otherwise, the business benefitsPublish API.The version and message are taken from the most recent entryChangelog.mdProject files.
  3. Automatically start pipelines for new Git tags. The pipeline publishesLatest,Mr,UnderageIrepairDocker analyzer image.

Steps to perform after publishing the analyzer

  1. Once the new version of the Docker analyzer image is tagged and deployed, test it with the appropriate test project.

  2. Announce the release in the relevant team Slack channel. Example message:

    (Video) Seven ways GitLab Premium will accelerate your development

    FYI, I just postedANALYZER_NAME ANALYZER_VERSION version.LINK_TO_RELEASE

Never delete a forwarded Git tagSince tags will likely be used and/or cached in the Go package registry.

FAQs

What does GitLab use for SAST? ›

GitLab SAST runs on merge requests and the default branch of your software projects so you can continuously monitor and improve the security of the code you write.

Which of the following SAST analyzers are supported in GitLab? ›

SAST supports the following official analyzers: bandit (Bandit) brakeman (Brakeman) eslint (ESLint (JavaScript and React))

Why GitLab is better than Jenkins? ›

Both Jenkins and Gitlab are designed to serve different requirements. While Jenkins boasts of a large plugin shelf, Gitlab is a comprehensive DevOps tool. While multiple plugins do your job efficiently, integration and management of these plugins might become a challenge when the project scales up.

What are the stages of GitLab CI workflow? ›

  • Build your application.
  • Secure your application.
  • Deploy and release your application.
  • Manage your infrastructure.
  • Experiment, Beta, GA support.
  • AI/ML powered features.

What is the difference between SAST and DAST in GitLab? ›

SAST is a security testing approach that is performed on the application's code, while DAST is an approach that is performed on the running application. Both SAST and DAST are essential components of a comprehensive security testing strategy for software applications.

What is the difference between SAST and DAST? ›

The main difference between DAST and SAST lies in how each performs the security testing. SAST scans the application code at rest to discover faulty code posing a security threat, while DAST tests the running application and has no access to its source code.

Which tool is best for SAST? ›

The 10 Best Static Application Security Testing Tools Summary
Tool
1GitHub Makes it easy to record and rewind changes made to code repositories.
2Dynatrace Providing deep observability with intelligent automation
3DeepSource Static code analysis made easy with minimal configuration and code health solutions
7 more rows
Jan 17, 2023

Why is SAST important? ›

Why is SAST Important? SAST is an essential step in the Software Development Life Cycle (SDLC) because it identifies critical vulnerabilities in an application before it's deployed to the public, while they're the least expensive to remediate.

How do you perform a SAST test? ›

  1. Finalize the tool. Select a static analysis tool that can perform code reviews of applications written in the programming languages you use. ...
  2. Create the scanning infrastructure, and deploy the tool. ...
  3. Customize the tool. ...
  4. Prioritize and onboard applications. ...
  5. Analyze scan results. ...
  6. Provide governance and training.

Why do people prefer GitLab? ›

Single application GitLab brings all DevSecOps capabilities into one application with a unified data store so everything is all in one place. Enhanced productivity GitLab's single application delivers a superior user experience, which improves cycle time and helps prevent context switching.

Is GitLab a CI CD tool? ›

GitLab has CI/CD built right in, no plugins required.

Why do companies use GitLab instead of GitHub? ›

GitLab is a repository that only lets its team of web developers collaborate on codes. GitHub doesn't allow locating a repository inside an organization in the free plan. GitLab allows its users to locate a repository inside an organization while using the free plan.

What are the 4 phases of CI implementation? ›

The CI/CD pipeline combines continuous integration, delivery and deployment into four major phases: source, build, test and deploy.

What are the 5 stages of CI CD pipeline? ›

  • CD Pipeline stages. The CD Pipeline has five stages: ...
  • Coding. The development teams can use any languages or frameworks they want.
  • Code Review. All changes have to be committed into the version control system.
  • BVT. ...
  • Staging. ...
  • Deployment. ...
  • Monitoring. ...
  • CI responsibilities.

What is the difference between pipeline and runner in GitLab? ›

What are the different stages of a GitLab CI/CD pipeline? Pipelines are comprised of jobs, which define what to do, such as compiling or testing code; stages, which define when to run the jobs; and runners, which are agents or servers that execute each job, and can spin up or down as needed.

Does GitLab have static code analysis? ›

The Static Analysis group at GitLab is charged with developing the following solutions for customer software repositories: Static Application Security Testing (SAST) Secret Detection. Code Quality.

What is the difference between GitLab artifacts and cache? ›

Cache is stored where GitLab Runner is installed and uploaded to S3 if distributed cache is enabled. Use artifacts to pass intermediate build results between stages. Artifacts are generated by a job, stored in GitLab, and can be downloaded.

What are the two phases of DAST? ›

An ASoC Dynamic (DAST) scan consists of two stages: Explore and Test. It is useful to understand the principal behind this, even though most of the scan process is seamless to the user, and no input is required until the scan is complete.

How do you perform SAST and DAST? ›

Dynamic security testing (DAST) uses the opposite approach of SAST. Whereas SAST tools rely on white-box testing, DAST uses a black-box approach that assumes testers have no knowledge of the inner workings of the software being tested, and have to use the available inputs and outputs.

What is the key benefit of DAST? ›

The major benefit of DAST tools is the ability for businesses to better understand how their web apps behave and identify threats early on in the SDLC. This enables businesses to save time and money by removing weaknesses and stopping malicious attacks before they happen.

What are the most common SAST vulnerabilities? ›

Examples of these problems are buffer overrun/underrun, use-after-free, type overrun/underrun, null string termination, not allocating space for string termination, and negative character value. Even the best of programmers violate these rules by accident occasionally.

What does SAST tool stand for? ›

Static application security testing (SAST) is a set of technologies designed to analyze application source code, byte code and binaries for coding and design conditions that are indicative of security vulnerabilities.

Which is combination of SAST and DAST? ›

What Is IAST? Interactive Application Security Testing (IAST) tools are developed to address the flaws in SAST and DAST tools by combining the two approaches. They are dynamic and identify issues during operation, like DAST, but run from inside the application server, and evaluate code like SAST.

What is the use of SAST and DAST tools in detecting application vulnerabilities? ›

​​SAST makes use of white-box testing to analyze the actual source code to detect and help remove potential vulnerabilities. DAST on the other hand doesn't access the source code and uses the process of black-box testing to scan a compiled, production-ready application to detect any vulnerabilities that exist within.

What are the challenges of SAST? ›

SAST challenges

However, scaling SAST can be difficult since it may require access to unavailable code or binaries, generate a lot of false positives or irrelevant findings, be slow and resource-intensive for large applications, and be hard to integrate with development lifecycles and tools.

Where does SAST comes in SDLC? ›

When can static application security testing be used? SAST should be deployed early in the implementation phase of the SDLC. because they don't need a running application to perform an analysis. Security teams therefore use SAST tools to scan applications during the coding process and before production.

What is the success criteria for SAST tool? ›

To be effective, a SAST solution should make its data and findings broadly accessible to other systems. Ideally, a SAST solution should have a broad set of pre-baked integrations with CI/CD tools, version control and code repositories, and other AppSec, DevOps, or DevEx tools.

What database does GitLab use? ›

GitLab.com is powered by a large PostgreSQL database ("the database" in this doc) which is often used as a point of reference in terms of scale - after all, this is the largest installation of GitLab we have access to.

Does GitLab use Azure or AWS? ›

GitLab is a DevOps platform with bring-your-own-infrastructure flexibility. From the on-premise to cloud, run GitLab on AWS and deploy to your workloads and AWS infrastructure using a single solution for everyone on your pipeline.

What server does GitLab use? ›

Our GitLab.com core infrastructure is primarily hosted in Google Cloud Platform's (GCP) us-east1 region (see Regions and Zones).

Which language is GitLab written in? ›

Is GitLab a Russian company? ›

GitLab was founded by Kharkiv developer Dmytro Zaporozhets and initially developed as a company in Ukraine.

What big companies use GitLab? ›

The company provides a central server that manages Git repositories and is used to simplify the administration tasks of many corporations worldwide. According to Wikipedia, GitLab has over 100,000 users and is used by large, well-known organizations such as IBM, Sony, Goldman Sachs, and NASA.

Videos

1. What Is GitLab Workflow | GitLab Flow | GitLab Tutorial For Beginners | Part III
(LambdaTest)
2. Learn GitLab in 3 Hours | GitLab Complete Tutorial For Beginners
(LambdaTest)
3. Wayne Haber (GitLab) - Open Practices in GitLab - IS Summit 21 Part 3
(InnerSource Commons)
4. GitLab Opportunity Canvas
(GitLab Unfiltered)
5. GitLab Release Management
(Black Diamond Learning)
6. Idea to Production with GitLab 10.2
(GitLab)

References

Top Articles
Latest Posts
Article information

Author: Annamae Dooley

Last Updated: 03/08/2023

Views: 5355

Rating: 4.4 / 5 (65 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Annamae Dooley

Birthday: 2001-07-26

Address: 9687 Tambra Meadow, Bradleyhaven, TN 53219

Phone: +9316045904039

Job: Future Coordinator

Hobby: Archery, Couponing, Poi, Kite flying, Knitting, Rappelling, Baseball

Introduction: My name is Annamae Dooley, I am a witty, quaint, lovely, clever, rich, sparkling, powerful person who loves writing and wants to share my knowledge and understanding with you.