Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
gitlab.com/gitlab-org/security-products/analyzers/common/v3
This repository contains Go packages you may use to create analyzers.
With the work in GitLab#211819 it is recommended to use the following dedicated modules:
command
Go package implements a CLI interface.common
project provides miscellaneous shared modules for logging, certificate handling, and directory search capabilities.report
Go package's Report
and Finding
structs marshal JSON reports.template
project scaffolds new analyzers.This project is in maintenance mode. As we transition away from a centralized module and towards separate projects, any future improvements should take into consideration whether the affected module should be extracted. In their current state, many of the modules are considered feature-complete and do not require updates, thereby not requiring extraction. This list includes the following modules:
common/cacert
common/logutil
common/pathfilter
common/plugin
common/search
common/walk
This section was moved to our development docs.
Analyzers are shipped as Docker images. For example, to run the semgrep Docker image to scan the working directory:
cd
into the directory of the source code you want to scan.docker login registry.gitlab.com
and provide username plus
personal
or project
access token with at least the read_registry
scope.docker run \
--interactive --tty --rm \
--volume "$PWD":/tmp/app \
--env CI_PROJECT_DIR=/tmp/app \
--env SECURE_LOG_LEVEL=debug \
-w /tmp/app \
registry.gitlab.com/gitlab-org/security-products/analyzers/semgrep:latest /analyzer run
gl-sast-report.json
.To update the analyzer:
Here's how to create a Docker image named analyzer
:
docker build -t analyzer .
For example, to test Secret Detection run the following:
wget https://gitlab.com/gitlab-org/security-products/ci-templates/-/raw/master/scripts/compare_reports.sh
sh ./compare_reports.sh sd test/fixtures/gl-secret-detection-report.json test/expect/gl-secret-detection-report.json \
| patch -Np1 test/expect/gl-secret-detection-report.json && git commit -m 'Update expectation' test/expect/gl-secret-detection-report.json
rm compare_reports.sh
You can also compile the binary for your own environment and run it locally
but analyze
and run
probably won't work
since the runtime dependencies of the analyzer are missing.
Here's an illustration based on spotbugs:
go build -o analyzer
./analyzer search test/fixtures
./analyzer convert test/fixtures/app/spotbugsXml.Xml > ./gl-sast-report.json
Video walkthrough of how Dependency Scanning analyzers are using multi-project pipeline feature to test analyzers using test projects:
If you want to test local changes in the shared modules (such as command
or report
) for an analyzer
you can do so by using the
go mod replace
directive to load command
with your local changes instead of using the version of command that has been
tagged remotely. For example:
go mod edit -replace gitlab.com/gitlab-org/security-products/analyzers/command/v3=/local/path/to/command
Alternatively you can achieve the same result by manually updating the go.mod
file:
module gitlab.com/gitlab-org/security-products/analyzers/awesome-analyzer/v2
replace gitlab.com/gitlab-org/security-products/analyzers/command/v3 => /path/to/command
require (
...
gitlab.com/gitlab-org/security-products/analyzers/command/v3 v2.19.0
)
If you want to use docker with replace
in the go.mod
file follow these steps:
command
into the directory of the analyzer. cp -r /path/to/command path/to/analyzer/command
.Dockerfile
: COPY command /command
.replace
statement to make sure it matches the destination of the COPY
statement in the step above:
replace gitlab.com/gitlab-org/security-products/analyzers/command/v3 => /command
Analyzers are independent projects that follow their own versioning. Patch
version bumps tend to correspond to a Minor
version bump of the underlying tools (i.e. bandit
), allowing us greater flexibility in reserving Minor
bumps for more significant changes to our scanners. In case of breaking changes imposed by the wrapped scanner, creating a new analyzer on a separate repository must be considered.
The analyzers are released as Docker images following this scheme:
master
branch will override the edge
image tagawesome-feature
branch will generate a matching awesome-feature
image tagMajor.Minor.Patch
image tag. A manual job allows to override the corresponding Major
and the latest
image tags to point to this Major.Minor.Patch
.To release a new analyzer Docker image, there are two different options:
CHANGELOG.md
entry for the new analyzer is correct.master
or main
branch) has a passing pipeline.Deployments
menu on the left-hand side of the project window, then selecting the Releases
sub-menu.New release
button to open the New Release
page.
Tag name
drop down, enter the same version used in the CHANGELOG.md
, for example v2.4.2
and select the option to create the tag (Create tag v2.4.2
here).Release title
enter the same version used above, for example v2.4.2
.Release notes
field, copy and paste the notes from the corresponding version in the CHANGELOG.md
.Create release
button.After following the above process and creating a new release, a new git tag will be created with the Tag name
provided above. This will trigger a new pipeline with the given tag version and a new analyzer Docker image will be built.
If the analyzer uses the analyzer.yml
template, then the pipeline triggered as part of the New release
process above will automatically tag and deploy a new version of the analyzer Docker image.
If the analyzer does not use the analyzer.yml
template, you'll need to manually tag and deploy a new version of the analyzer Docker image using these steps:
CI/CD
menu on the left-hand side of the project window, then select the Pipelines
sub-menu.v2.4.2
blocked
state.Manual job
play button on the right hand side of the window and select tag version
to tag and deploy a new version of the analyzer Docker imageUse your best judgment to decide when to create a git tag, which will then trigger the release job. If you can't decide, then ask for other's input.
The following must be performed before the automatic release process can be used:
CREATE_GIT_TAG: true
as a CI/CD
environment variable.Variables
in the CI/CD project settings. Unless the project already inherits the GITLAB_TOKEN
environment variable from the project group, create a project access token with complete read/write access to the API
and configure GITLAB_TOKEN
as a CI/CD
environment variable which refers to this token.Once the above steps have been completed, the automatic release process executes as follows:
upsert git tag
job is executed.
CHANGELOG.md
matches one of the git tags, the job is a no-op.CHANGELOG.md
file for the project.latest
, major
, minor
and patch
Docker images of the analyzer.Once a new version of the analyzer Docker image has been tagged and deployed, please test it with the corresponding test project.
Announce the release on the relevant group slack channel. Example message:
FYI I've just released
ANALYZER_NAME
ANALYZER_VERSION
.LINK_TO_RELEASE
Never delete a git tag that has been pushed as there is a good chance that the tag will be used and/or cached by the Go package registry.
Contributions are welcome, see CONTRIBUTING.md
for more details.
This code is distributed under the MIT Expat license, see the LICENSE file.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.