Skip to content

Commit 89e6f47

Browse files
MDBF-143: Add Infer builder
This preforms static analysis on the MariaDB codebase by maintaining a git source repository as a shared volume. Because static analysis takes time, a lot of time, there is a shared cache volume to store build results from main branches of the codebase so that as much incremental usage can occur. Infer runs in to phases, a capture and an analyze. Infer output are in a result-dir this contains: * report.json - what infer tools use * report.txt - the human readable version of this * capture.db - the sqlite3 version presentation of captured files and the relation to functions definitions. * results.db - the analyze phase outputs Of these, the report.json is desirable as the long term record of vulnerabilities. and the main_diff containing the difference from the last main X.Y branch commit.
1 parent 406f017 commit 89e6f47

7 files changed

Lines changed: 476 additions & 8 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import os
2+
3+
from configuration.builders.infra.runtime import (
4+
BuildSequence,
5+
DockerConfig,
6+
InContainer,
7+
)
8+
from configuration.steps.base import StepOptions
9+
from configuration.steps.commands.base import URL
10+
from configuration.steps.commands.packages import SavePackages
11+
from configuration.steps.commands.util import InferScript, PrintEnvironmentDetails
12+
from configuration.steps.remote import ShellStep
13+
14+
15+
def infer(config: DockerConfig):
16+
sequence = BuildSequence()
17+
18+
sequence.add_step(ShellStep(command=PrintEnvironmentDetails()))
19+
20+
sequence.add_step(
21+
InContainer(
22+
docker_environment=config,
23+
step=ShellStep(
24+
command=InferScript(),
25+
options=StepOptions(
26+
description="running infer analysis",
27+
descriptionDone="infer analysis complete",
28+
),
29+
env_vars=[("JOBS", str("%(prop:jobs)s"))],
30+
),
31+
)
32+
)
33+
34+
sequence.add_step(
35+
InContainer(
36+
docker_environment=config,
37+
step=ShellStep(
38+
command=SavePackages(
39+
packages=["infer_results"],
40+
destination="/packages/%(prop:tarbuildnum)s/logs/%(prop:buildername)s",
41+
),
42+
url=URL(
43+
url=f"{os.environ['ARTIFACTS_URL']}/%(prop:tarbuildnum)s/logs/%(prop:buildername)s",
44+
url_text="Infer artifacts/logs",
45+
),
46+
options=StepOptions(
47+
alwaysRun=True,
48+
description="saving infer analysis results",
49+
descriptionDone="infer analysis results saved",
50+
),
51+
),
52+
)
53+
)
54+
return sequence

configuration/steps/commands/base.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,14 @@ def as_cmd_arg(self) -> list[str]:
6262

6363

6464
class BashCommand(Command):
65-
def __init__(self, cmd: str, name: str = "Run command", user: str = "buildbot"):
66-
super().__init__(name=name, workdir=PurePath("."), user=user)
65+
def __init__(
66+
self,
67+
cmd: str,
68+
name: str = "Run command",
69+
user: str = "buildbot",
70+
workdir: PurePath = PurePath("."),
71+
):
72+
super().__init__(name=name, workdir=workdir, user=user)
6773
self.cmd = cmd
6874

6975
def as_cmd_arg(self) -> list[str]:

0 commit comments

Comments
 (0)