Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Sicherheitslücken (CVE)5 ways AI is reshaping the cybersecurity job market(21.09.2026 um 10:25 Uhr)
IT Security NachrichtenRevoking the token didn’t kill the backdoor(21.09.2026 um 11:00 Uhr)
Malware / Trojaner / VirenChainScript-RAT per Polygon: ClickFix-Kampagnen drehen C2-Infrastruktur(21.09.2026 um 10:55 Uhr)
IT Security NachrichtenEnterprise Mobile KI: So lassen sich Shadow-AI-Risiken kontrollieren(21.09.2026 um 12:00 Uhr)
Malware / Trojaner / VirenChainScript-RAT setzt auf Polygon-Blockchain für C2-Rotation(21.09.2026 um 12:19 Uhr)
Sicherheitslücken (CVE)5 ways AI is reshaping the cybersecurity job market(21.09.2026 um 10:25 Uhr)
IT Security NachrichtenRevoking the token didn’t kill the backdoor(21.09.2026 um 11:00 Uhr)
Malware / Trojaner / VirenChainScript-RAT per Polygon: ClickFix-Kampagnen drehen C2-Infrastruktur(21.09.2026 um 10:55 Uhr)
IT Security NachrichtenEnterprise Mobile KI: So lassen sich Shadow-AI-Risiken kontrollieren(21.09.2026 um 12:00 Uhr)
Malware / Trojaner / VirenChainScript-RAT setzt auf Polygon-Blockchain für C2-Rotation(21.09.2026 um 12:19 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Semgrep Observability with OpenTelemetry

Semgrep is a great open source security and code validation tool. Semgrep revolves around rules like this: rules: - id: print-to-logger pattern: print($VAR) message: Use logging.info() instead of print() language: python …

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Semgrep is a great open source security and code validation tool. Semgrep revolves around rules like this:




rules:
- id: print-to-logger
pattern: print($VAR)
message: Use logging.info() instead of print()
language: python
severity: MEDIUM
fix: logger.info($MSG)






The rule above will raise a MEDIUM severity issue every time a use of print() is used in your Python code. It will also provide the recommended fix and even take the value inside the print statement and produce the fix content. Thus print("Hello world!") becomes logger.info("Hello world!")



The rules.yaml file is then used to validate one or more (in this case) Python files:




semgrep scan -f rules.yaml app.py









Capturing Semgrep Output using the OpenTelemetry Collector



Semgrep is capable of producing JSON output which means it's really easy to grab using the OpenTelemetry collector. Let's re-run the previous command with a few more flags to produce JSON:




semgrep scan -f rules.yaml --json -o out.json app.py






It produces single line JSON (JSONL) like this (which I've expanded here for readability):




{
"version": "1.152.0",
"results": [
// Rule violations are listed here...
{
"check_id": "print-to-logger",
"path": "app.py",
"start": {
"line": 4,
"col": 5,
"offset": 46
},
"end": {
"line": 4,
"col": 18,
"offset": 59
},
"extra": {
"message": "Use logging.info() instead of print()",
"fix": "logger.info(\"blah\")",
"metadata": {},
"severity": "MEDIUM",
"fingerprint": "requires login",
"lines": "requires login",
"validation_state": "NO_VALIDATOR",
"engine_kind": "OSS"
}
},
...
],
"rules": [],
"rules_parse_time": 0.0018589496612548828,
"profiling_times": {
"config_time": 0.1376628875732422,
"core_time": 0.2947859764099121,
"ignores_time": 4.291534423828125e-05,
"total_time": 0.43769073486328125
},
"parsing_time": {
"total_time": 0.0,
"per_file_time": {
"mean": 0.0,
"std_dev": 0.0
},
"very_slow_stats": {
"time_ratio": 0.0,
"count_ratio": 0.0
},
"very_slow_files": []
},
"scanning_time": {
"total_time": 0.009443998336791992,
"per_file_time": {
"mean": 0.009443998336791992,
"std_dev": 0.0
},
"very_slow_stats": {
"time_ratio": 0.0,
"count_ratio": 0.0
},
"very_slow_files": []
},
"matching_time": {
"total_time": 0.0,
"per_file_and_rule_time": {
"mean": 0.0,
"std_dev": 0.0
},
"very_slow_stats": {
"time_ratio": 0.0,
"count_ratio": 0.0
},
"very_slow_rules_on_files": []
},
"tainting_time": {
"total_time": 0.0,
"per_def_and_rule_time": {
"mean": 0.0,
"std_dev": 0.0
},
"very_slow_stats": {
"time_ratio": 0.0,
"count_ratio": 0.0
},
"very_slow_rules_on_defs": []
},
"fixpoint_timeouts": [],
"prefiltering": {
"project_level_time": 0.0,
"file_level_time": 0.0,
"rules_with_project_prefilters_ratio": 0.0,
"rules_with_file_prefilters_ratio": 1.0,
"rules_selected_ratio": 1.0,
"rules_matched_ratio": 1.0
},
"targets": [],
"total_bytes": 0,
"max_memory_bytes": 120384832
}






Configure the OpenTelemetry collector to:




  1. Monitor out.json

  2. Parse the body text as JSON



The transform processor can also be used to process the JSONL lines as they transit through the collector. In this case the rules:




  1. Set both the time and observed_time to the current time (since the log line doesn't explicitly state a timestamp

  2. Adds a new Key/Value attribute pair to each log record of tool: semgrep (this is useful when the log line hits your Observability backend for filtering)

  3. Adds another new Key/Value attribute pair to each log record where the key == results_found and the value is the length of the results array (again useful for backend processing - your O11y system may be able to compute lengths from an input array, but you can add it here to offload the processing / cost)

  4. The final two rules effectively overwrite the version key as semgrep_version.




Note: The collector cannot rename attribute keys so you actually take the current value of version (ie. "1.152.0"), create a new attribute called semgrep_version, set the value of the value using the existing value and finally delete the existing version attribute.





receivers:
filelog:
include: [out.json]
start_at: beginning
operators:
- type: json_parser
parse_from: body

processors:
transform:
error_mode: ignore
log_statements:
- statements:
- set(log.time, Now())
- set(log.observed_time, Now())
- set(log.attributes["tool"], "semgrep")
- set(log.attributes["results_found"], Len(log.attributes["results"]))
- set(log.attributes["semgrep_version"], log.attributes["version"])
- delete_key(log.attributes, "version")

exporters:
debug:
verbosity: detailed

service:
pipelines:
logs:
receivers: [filelog]
processors: [transform]
exporters: [debug]









Save Money by shrinking output on no violations



The output can be a bit wordy even when there are no violations. We can shrink this using the transform processor with an additional rule:




- set(log.body, "Semgrep scan finished. No issues found.") where Len(log.attributes["results"]) == 0









Create metrics from log content



Notice there are lots of metric fields in the JSON so use the signal_to_metrics connector to transform log content to real OpenTelemetry metrics.



Add this content to the collector YAML (connectors should be at the same level as receivers and processors.



Then add the signal_to_metrics as both an output of the logs pipeline and an input to a metrics pipeline (that you need to define).



The idea here is that logs flow into the connector, are transformed to metrics and into the metrics pipeline they go.




connectors:
signal_to_metrics:
logs:
- name: max_memory_bytes
description: Extract the first number from the string
gauge:
value: Double(log.attributes["time"]["max_memory_bytes"])
- name: profiling_times.config_time
description: Extract the first number from the string
gauge:
value: Double(log.attributes["time"]["profiling_times"]["config_time"])

...

service:
pipelines:
logs:
receivers: [filelog]
processors: [transform]
exporters: [debug, signal_to_metrics]
metrics:
receivers: [signal_to_metrics]
processors: []
exporters: [debug]









Summary



Semgrep is a great security and validation tool and the results are really easy to process using the OpenTelemetry collector.



Subscribe to me on YouTube for more Observability and OpenTelemetry content.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Semgrep Observability with OpenTelemetry

Thematisch verwandte Begriffe: Semgrep, Observability, with, OpenTelemetry · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-94036 | A security flaw has been discovered in D-Link DIR-X1860 and DIR-X1860Z u…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick