# DOCKER-BP-019: Avoid zypper update

> **Severity:** MEDIUM | **CWE:** CWE-710

- **Language:** Docker
- **Category:** Best Practice
- **URL:** https://codepathfinder.dev/registry/docker/best-practice/DOCKER-BP-019
- **Detection:** `pathfinder scan --ruleset docker/DOCKER-BP-019 --project .`

## Description

Detects use of 'zypper update' in Dockerfiles. Running system updates in Docker builds
creates unpredictable, non-reproducible images and can introduce breaking changes or
security vulnerabilities.

## Vulnerable Code

```python
FROM opensuse/leap:latest
RUN zypper update -y  # Bad: Unpredictable, non-reproducible builds
RUN zypper install -y nginx
```

## Secure Code

```python
FROM opensuse/leap:15.4  # Specific version
RUN zypper install -y nginx-1.21.6-1
# Or install latest from specific base image
RUN zypper install -y nginx
```

## Detection Rule (Python SDK)

```python
from rules.container_decorators import dockerfile_rule
from rules.container_matchers import instruction


@dockerfile_rule(
    id="DOCKER-BP-019",
    name="Avoid zypper update",
    severity="MEDIUM",
    cwe="CWE-710",
    category="best-practice",
    tags="docker,dockerfile,zypper,package-manager,opensuse,suse,update,reproducibility,best-practice,anti-pattern",
    message="Avoid 'zypper update' in Dockerfiles. Use specific base image versions for reproducible builds."
)
def avoid_zypper_update():
    return instruction(type="RUN", contains="zypper update")
```

## How to Fix

- Review your Dockerfile to address the avoid zypper update issue
- Follow Docker official best practices for image building
- Use docker build --check to validate Dockerfile syntax and best practices

## FAQ

**Q: Why does this rule flag avoid zypper update?**

Avoid 'zypper update' in Dockerfiles. Use specific base image versions for reproducible builds.

**Q: How do I fix this?**

Review the secure code example in the playground above and apply the recommended pattern to your Dockerfile or docker-compose.yml.

## References

- [Docker Best Practices](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/)
- [Dockerfile Best Practice: Avoid zypper update](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run)

---

Source: https://codepathfinder.dev/registry/docker/best-practice/DOCKER-BP-019
Code Pathfinder — Open source, type-aware SAST with cross-file dataflow analysis
