A higher resolution is required to access the IDE
- 1
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
As a SecOps engineer, you must ensure that sensitive data never leaks into application logs.For the purposes of this task, tokens are defined as being bounded by non-alphanumeric characters or the beginning or end of the line.
Inspect a stream of server log lines and sanitize all occurrences of the following two patterns, subject to the overlapping rule:
1. Credit card numbers
Exactly four consecutive tokens, each consisting of exactly 4 digits and joined by
2. API token
A token
Overlapping rule
Overlapping occurrences of a single pattern should not be considered to fit the pattern and should remain unchanged. For example, this applies to:
• Five or more consecutive tokens, each consisting of exactly 4 digits and joined by
•
If
All other log characters must remain untouched.
Input
Line 1: An integer N for the number of log lines.
Next N lines: A string line representing a raw log entry.
Next N lines: A string line representing a raw log entry.
Output
N lines: The sanitized log entries.
Constraints
1 ≤ N ≤ 10
line contains between 1 and 100 printable ASCII characters.
line contains between 1 and 100 printable ASCII characters.
Example
Input
4 [SYSTEM] Server running on port 8080 with 0 errors. [TRANSFER] Moved funds from 8291-3849-1029-4820 to 5731-4921-5829-1039 confirmed. 192.168.1.1 - GET /auth?token=abC123XyZ HTTP/1.1 2023-10-01 12:00:00 INFO: Session initiated, token=validToken123 login success
Output
[SYSTEM] Server running on port 8080 with 0 errors. [TRANSFER] Moved funds from [CARD_REDACTED] to [CARD_REDACTED] confirmed. 192.168.1.1 - GET /auth?token=[TOKEN_REDACTED] HTTP/1.1 2023-10-01 12:00:00 INFO: Session initiated, token=[TOKEN_REDACTED] login success
A higher resolution is required to access the IDE