dsh-data-lifecycle: Static Check for Data Retention Periods and Expiration Cleanup Paths

Introduction

Three common types of “data accumulation” issues exist in business systems: database tables, logs, and upload directories continue to grow, but documentation fails to specify retention durations; configurations contain excessively long retention periods like expireAfterDays: 3650; and code consists entirely of INSERT and disk writes, lacking purge, expiry deletion, or scheduled cleanup mechanisms. In compliance discussions, dsh-cn-log-retention focuses on whether logs meet the legal minimum retention period (e.g., whether 6 months are retained); another type of problem is “how long various types of data are retained and whether anyone deletes them upon expiration” — this is exactly the gap that data lifecycle checks aim to address.

Below is an introduction to the DSH plugin @deepwhale-cn/dsh-data-lifecycle (repository feely0208/dsh-data-lifecycle). It performs static scanning on project source code and configurations, describing facts and providing rule hit locations. It does not conclude on “violations” nor does it delete data for you.

What is this

Maintainer: feely0208. npm package name @deepwhale-cn/dsh-data-lifecycle, current version 0.1.0, MIT License. Categorized under admin-security.

Is: A static check tool targeting three gaps in “data retention”: ① Data is persisted but no documented retention period is found; ② Retention periods are set to more than 3 years (1095 days / 36 months, including expireAfterDays: 3650); ③ Write paths exist but no cleanup/expiry deletion implementation is found. It also provides weak signals: scheduled tasks lack cleanup items, and table structures lack fields like expires_at / deleted_at.

Is Not: A runtime cleanup tool; Data classification and grading (see dsh-data-classify); Specifically for checking “whether logs are retained for 6 months” (see dsh-cn-log-retention); User rights fulfillment for deletion (see dsh-data-rights). In short: dsh-cn-log-retention checks “if enough is retained,” while this plugin checks “if it is retained too long / if it should be deleted but wasn’t.”

For purely frontend projects or pure tool libraries without database/log/upload persistence traces, the initial rules with “applicability prerequisites” will not produce false positives.

Core Features: Five Rules

Each hit provides the file, line number, content of the line, and the source of the legal clause cited (which can be verified against the original text).

Rule ID What it Checks Level
LIFE-NO-RETENTION-POLICY Data is persisted, but no documented retention period regulation is found High
LIFE-RETENTION-TOO-LONG Retention period is set to more than 3 years / more than 1095 days High
LIFE-WRITE-NO-PURGE Write paths exist, but no cleanup/expiry deletion implementation is found in the entire codebase High
LIFE-SCHEDULE-NO-CLEANUP Scheduled tasks exist, but none of them are for cleanup Medium
LIFE-SCHEMA-NO-EXPIRY-FIELD No fields like expires_at / deleted_at in table creation/models Low (Weak Signal)

The correlation with the Personal Information Protection Law (PIPL) and Cybersecurity Law found in the README (excerpted from official docs for clarity regarding division of labor with sibling plugins):

dsh-cn-log-retention  = Is the log retention enough for 6 months? (Legal minimum, Cybersecurity Law Art. 21)
dsh-data-lifecycle    = How long is various data kept, and is anyone deleting it upon expiration? (PIPL Art. 19 / 47)
dsh-data-classify     = Is data classified/graded, and is there a ledger?
dsh-data-rights       = Can data be deleted when a user requests it?
dsh-pipia             = Does the PIA report itself need to be kept for 3 years? (PIPL Art. 56)

Installation and Usage

Requires Node.js >= 18 and DSH Engine >=0.1.0-rc.6 <0.3.0. The official installation command is:

dsh plugin --profile web add @deepwhale-cn/dsh-data-lifecycle

The plugin reads the specified project directory with the permissions of the current DSH process. Before installation, please review the GitHub Repository source code and MIT License to ensure it meets your security and compliance procedures.

Typical Usage

After installation, invoke it via the command dsh-data-lifecycle (see package.json bin configuration).

  1. Scan the project in the current working directory:
dsh-data-lifecycle
  1. Scan a specific root directory:
dsh-data-lifecycle --root /path/to/project
  1. View the built-in demo (a membership center sample that “only writes to the DB, never deletes, and has no written retention period”):
dsh-data-lifecycle --demo
  1. List rules and citations:
dsh-data-lifecycle --list-rules
  1. Generate an HTML report:
dsh-data-lifecycle --root /path/to/project --html report.html

What you will see in the Demo Sample

The membership center in --demo has a package.json, table structures, upload interfaces, logs, and daily scheduled tasks, but lacks the design to “make data disappear.” The hit patterns recorded in the README include: retention periods not explicitly written in multiple places; expireAfterDays: 3650 in src/media/expiry.js; writes without purge; jobs/nightly-report.js cron doing daily reports instead of cleanup; and migration SQL creating tables without expires_at / deleted_at.

The passing sample is located at tests/fixtures/pass/clean-project/: README has a retention period table, config/retention.yml specifies 180 / 90 days, jobs/purge-expired.js cleans up daily at 03:00, and tables contain expires_at—expecting 0 hits.

Applicable Scenarios and Notes

Suitable for: Performing a quick survey on backend/full-stack repositories to check “if retention strategies are written and if deletion paths exist” before changing architecture or supplementing compliance documentation; combining with sibling plugins like dsh-cn-log-retention, dsh-data-classify, dsh-data-rights to cover chain security issues.

Boundaries (Explicitly stated in README):

  • Performs static checks only. If cleanup is done at the deployment layer (e.g., object storage lifecycle, database partitioning, DBA scripts), the scan cannot see it and may still prompt you for manual confirmation.
  • Primarily identifies common naming conventions like retention / expire / purge / cleanup; custom function names may be missed.
  • Does not check runtime: whether data is actually deleted or if backups are still retained requires your own operations and processes to guarantee.
  • Hit results are prompts for confirmation, not violation determinations; situations requiring long-term retention according to law should have their basis stated in documentation.

Links

The DSH ecosystem emphasizes “Everything is a plugin”; the community directory is an independent site and has no official affiliation with DeepSeek / High-Flyer. This plugin belongs to the “Data and Credentials” direction of the DeepWhale Cybersecurity Guard series and can be used in combination with other guard plugins from the same maintainer.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye