forked from vibemafiaclub/argos
-
Notifications
You must be signed in to change notification settings - Fork 0
fix(csv): neutralize spreadsheet formula prefixes in session export #587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
seonghobae
wants to merge
10
commits into
developmental
Choose a base branch
from
sentinel-csv-injection-14493010797505717678
base: developmental
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b697ea0
🛡️ Sentinel: [HIGH] CSV 매크로 인젝션 취약점 수정
seonghobae f62ec8d
🛡️ Sentinel: [HIGH] CSV 매크로 인젝션 취약점 수정 (trigger ci)
seonghobae c4331de
test(csv): cover ASVS null formula trigger
seonghobae 22a8a0c
fix(csv): cover the complete ASVS formula-trigger prefix set
seonghobae 33bf798
chore(security): restore protected Sentinel authority
seonghobae 819fc1f
🛡️ Sentinel: [HIGH] 취약점 패키지 업데이트 (browserslist, deepmerge-ts)
seonghobae 8f8258c
🛡️ Sentinel: [HIGH] 취약점 패키지 업데이트 (browserslist, deepmerge-ts) (trigge…
seonghobae 0f272c0
🛡️ Sentinel: [HIGH] 취약점 패키지 업데이트 (browserslist, deepmerge-ts) (trigge…
seonghobae 72e794b
🛡️ Sentinel: [HIGH] 취약점 패키지 업데이트 (browserslist, deepmerge-ts) (trigge…
seonghobae a41c8c9
🛡️ Sentinel: [HIGH] 취약점 패키지 업데이트 (browserslist, deepmerge-ts) (trigge…
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { describe, it, expect } from 'vitest' | ||
| import { csvField } from './export' | ||
|
|
||
| describe('csvField', () => { | ||
| it('escapes macro injection characters', () => { | ||
| expect(csvField('=1+1')).toBe("'=1+1") | ||
| expect(csvField('+1+1')).toBe("'+1+1") | ||
| expect(csvField('-1+1')).toBe("'-1+1") | ||
| expect(csvField('@1+1')).toBe("'@1+1") | ||
| expect(csvField('\t1+1')).toBe("'\t1+1") | ||
| expect(csvField('\r1+1')).toBe("\"'\r1+1\"") | ||
| expect(csvField('\n1+1')).toBe("\"'\n1+1\"") | ||
| expect(csvField(' =1+1')).toBe("' =1+1") | ||
| expect(csvField('\uFF1D1+1')).toBe("'\uFF1D1+1") | ||
| }) | ||
|
|
||
| it('preserves numbers', () => { | ||
| expect(csvField(123)).toBe('123') | ||
| expect(csvField(-123)).toBe('-123') | ||
| expect(csvField(0)).toBe('0') | ||
| }) | ||
|
|
||
| it('escapes quotes and newlines', () => { | ||
| expect(csvField('hello\nworld')).toBe('"hello\nworld"') | ||
| expect(csvField('hello"world')).toBe('"hello""world"') | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| export function csvField(value: string | number | null | undefined) { | ||
| if (value === null || value === undefined) return '' | ||
|
|
||
| if (typeof value === 'string') { | ||
| // Prevent CSV Injection (Macro Injection) | ||
| if (/^[=+\-@\t\r\n\uFF1D\uFF0B\uFF0D\uFF20]/.test(value)) { | ||
| value = `'${value}` | ||
| } else { | ||
| const trimmed = value.replace(/^\s+/, '') | ||
| if (trimmed.length !== value.length && /^[=+\-@\t\r\n\uFF1D\uFF0B\uFF0D\uFF20]/.test(trimmed)) { | ||
| value = `'${value}` | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const text = String(value) | ||
| return /[",\r\n]/.test(text) ? `"${text.replaceAll('"', '""')}"` : text | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
null및undefined입력 테스트를 추가하세요.csvField는 두 입력을 빈 필드로 변환하지만, 현재 테스트는 이 분기를 실행하지 않습니다. 이 경로가 회귀하면 CSV에null또는undefined가 문자열로 출력될 수 있습니다.테스트 추가 예시
it('preserves numbers', () => { + expect(csvField(null)).toBe('') + expect(csvField(undefined)).toBe('') expect(csvField(123)).toBe('123')📝 Committable suggestion
🤖 Prompt for AI Agents