Skip to content

Commit e1e9ab3

Browse files
authored
more fs patterns (#136)
1 parent 07c4ae9 commit e1e9ab3

27 files changed

+1219
-0
lines changed

shellfirm/checks/fs.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,55 @@
2424
test: find\s.*-delete
2525
description: "Did you -delete flag in the wrong order? find -delete going to delete all the file under your current path."
2626
id: fs:delete_find_files
27+
- from: fs
28+
test: 'dd\s+.*of=/dev/([hs]d[a-z]|mmcblk[0-9])'
29+
description: "Are you sure you want to write directly to a block device? This could overwrite your disk."
30+
id: fs:dd_block_device
31+
- from: fs
32+
test: 'mkfs(?:\.(?:ext[2-4]|fat|ntfs|xfs|btrfs))?\s+(?:-t\s+\w+\s+)?/dev/([hs]d[a-z][0-9]*|mmcblk[0-9]p?[0-9]*)'
33+
description: "Are you sure you want to format this device? This will erase all data on it."
34+
id: fs:mkfs_format
35+
- from: fs
36+
test: 'parted\s+.*(/dev/([hs]d[a-z]|mmcblk[0-9]))'
37+
description: "Are you sure you want to modify disk partitions? This could erase all data on the disk."
38+
id: fs:parted_disk_modify
39+
- from: fs
40+
test: 'fdisk\s+.*(/dev/([hs]d[a-z]|mmcblk[0-9]))'
41+
description: "Are you sure you want to modify disk partitions? This could erase all data on the disk."
42+
id: fs:fdisk_disk_modify
43+
- from: fs
44+
test: 'sfdisk\s+.*(/dev/([hs]d[a-z]|mmcblk[0-9]))'
45+
description: "Are you sure you want to modify disk partitions? This could erase all data on the disk."
46+
id: fs:sfdisk_disk_modify
47+
- from: fs
48+
test: 'dd\s+.*(?:conv=notrunc|seek=\d+|skip=\d+).*of=/dev/([hs]d[a-z]|mmcblk[0-9])'
49+
description: "Are you sure you want to write to a specific sector of the disk? This could corrupt data."
50+
id: fs:dd_advanced_disk_write
51+
- from: fs
52+
test: 'gdisk\s+.*(/dev/([hs]d[a-z]|mmcblk[0-9]))'
53+
description: "Are you sure you want to modify GPT disk partitions? This could erase all data on the disk."
54+
id: fs:gdisk_disk_modify
55+
- from: fs
56+
test: 'partprobe\s+.*(/dev/([hs]d[a-z]|mmcblk[0-9]))'
57+
description: "Are you sure you want to inform the OS of partition table changes? This could affect mounted partitions."
58+
id: fs:partprobe_disk_update
59+
- from: fs
60+
test: 'blockdev\s+.*(/dev/([hs]d[a-z]|mmcblk[0-9]))'
61+
description: "Are you sure you want to modify block device parameters? This could affect disk operations."
62+
id: fs:blockdev_disk_modify
63+
- from: fs
64+
test: 'mount\s+.*(/dev/([hs]d[a-z]|mmcblk[0-9]))'
65+
description: "Are you sure you want to mount this device? This could affect system stability."
66+
id: fs:mount_operations
67+
- from: fs
68+
test: '(?:lvremove|pvremove|vgremove)\s+.*(/dev/([hs]d[a-z]|mmcblk[0-9]))'
69+
description: "Are you sure you want to remove this logical volume/volume group? This will delete all data."
70+
id: fs:lvm_operations
71+
- from: fs
72+
test: '(?:dump|restore)\s+.*(/dev/([hs]d[a-z]|mmcblk[0-9]))'
73+
description: "Are you sure you want to backup/restore this filesystem? This could affect system stability."
74+
id: fs:filesystem_backup
75+
- from: fs
76+
test: 'cryptsetup\s+.*(/dev/([hs]d[a-z]|mmcblk[0-9]))'
77+
description: "Are you sure you want to encrypt/decrypt this device? This could affect data accessibility."
78+
id: fs:encryption_operations
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
- test: blockdev --setro /dev/sda
3+
description: match setting read-only mode
4+
- test: blockdev --setrw /dev/sda
5+
description: match setting read-write mode
6+
- test: blockdev --flushbufs /dev/sda
7+
description: match flushing buffers
8+
- test: blockdev --rereadpt /dev/sda
9+
description: match rereading partition table
10+
- test: blockdev --report /dev/sda
11+
description: match reporting device information
12+
- test: blockdev --getro /dev/sda
13+
description: match getting read-only status
14+
- test: blockdev --getss /dev/sda
15+
description: match getting sector size
16+
- test: blockdev --report
17+
description: should not match reporting all devices without modification
18+
- test: blockdev --report /tmp/test.img
19+
description: should not match regular file
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
- test: dd if=file of=/dev/sda seek=1
3+
description: match writing at specific sector
4+
- test: dd if=file of=/dev/sda conv=notrunc
5+
description: match writing without truncating
6+
- test: dd if=/dev/sda of=file skip=1
7+
description: match reading from specific sector
8+
- test: dd if=file of=/dev/sda seek=2048 bs=512
9+
description: match writing at specific sector with block size
10+
- test: dd if=file of=/dev/sda conv=notrunc,noerror
11+
description: match writing with multiple conversion options
12+
- test: dd if=file of=/dev/sda seek=1 skip=1
13+
description: match writing with both seek and skip
14+
- test: dd if=file of=/dev/sda bs=4M seek=1
15+
description: match writing with large block size
16+
- test: dd if=file of=output.txt
17+
description: should not match regular file operations
18+
- test: dd if=/dev/sda of=backup.img
19+
description: should not match reading from disk
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
- test: dd if=image.img of=/dev/sda
3+
description: match command writing to hard disk
4+
- test: dd if=image.img of=/dev/sdb
5+
description: match command writing to second hard disk
6+
- test: dd if=image.img of=/dev/mmcblk0
7+
description: match command writing to SD card
8+
- test: dd if=image.img of=/dev/sda1
9+
description: match command writing to partition
10+
- test: dd if=image.img of=/dev/sda bs=4M
11+
description: match command with block size parameter
12+
- test: dd if=/dev/sda of=backup.img
13+
description: should not match reading from disk
14+
- test: dd if=file.txt of=output.txt
15+
description: should not match regular file operations
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
- test: cryptsetup luksFormat /dev/sda1
3+
description: match formatting LUKS partition
4+
- test: cryptsetup open /dev/sda1 my_encrypted
5+
description: match opening encrypted device
6+
- test: cryptsetup close my_encrypted /dev/sda1
7+
description: match closing encrypted device
8+
- test: cryptsetup luksAddKey /dev/sda1
9+
description: match adding LUKS key
10+
- test: cryptsetup luksRemoveKey /dev/sda1
11+
description: match removing LUKS key
12+
- test: cryptsetup luksDump /dev/sda1
13+
description: match dumping LUKS header
14+
- test: cryptsetup resize my_encrypted /dev/sda1
15+
description: match resizing encrypted device
16+
- test: cryptsetup -v status my_encrypted
17+
description: should not match checking status
18+
- test: cryptsetup isLuks /dev/sda1
19+
description: match checking if LUKS
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
- test: fdisk /dev/sda
3+
description: match interactive partition editor
4+
- test: fdisk -l /dev/sda
5+
description: match listing partitions
6+
- test: fdisk -w /dev/sda
7+
description: match writing changes
8+
- test: fdisk -u /dev/sda
9+
description: match using sectors instead of cylinders
10+
- test: fdisk -b 2048 /dev/sda
11+
description: match specifying sector size
12+
- test: fdisk -c /dev/sda
13+
description: match disabling DOS compatibility mode
14+
- test: fdisk -w always /dev/sda
15+
description: match writing changes without confirmation
16+
- test: fdisk -l
17+
description: should not match listing all devices without modification
18+
- test: fdisk /tmp/test.img
19+
description: should not match regular file
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
- test: dump -0f /backup.dump /dev/sda1
3+
description: match creating filesystem dump
4+
- test: restore -rf /backup.dump /dev/sda1
5+
description: match restoring from dump
6+
- test: dump -0u /dev/sda1
7+
description: match updating dump
8+
- test: dump -0f /backup.dump -b 1024 /dev/sda1
9+
description: match dump with block size
10+
- test: restore -rf -b 1024 /backup.dump /dev/sda1
11+
description: match restore with block size
12+
- test: dump -0f /backup.dump -z 9 /dev/sda1
13+
description: match compressed dump
14+
- test: restore -rf -z /backup.dump /dev/sda1
15+
description: match compressed restore
16+
- test: dump -0f /backup.dump /tmp/test.img
17+
description: should not match dumping regular file
18+
- test: restore -rf /backup.dump /tmp/test.img
19+
description: should not match restoring to regular file
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
- test: gdisk /dev/sda
3+
description: match interactive GPT partition editor
4+
- test: gdisk -l /dev/sda
5+
description: match listing GPT partitions
6+
- test: gdisk -w /dev/sda
7+
description: match writing GPT changes
8+
- test: gdisk -o /dev/sda
9+
description: match creating new GPT partition table
10+
- test: gdisk -r /dev/sda
11+
description: match recovery and transformation
12+
- test: gdisk -v /dev/sda
13+
description: match verification
14+
- test: gdisk -p /dev/sda
15+
description: match printing partition table
16+
- test: gdisk -l
17+
description: should not match listing all devices without modification
18+
- test: gdisk /tmp/test.img
19+
description: should not match regular file
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
- test: lvremove /dev/vg0/lv1
3+
description: match removing logical volume
4+
- test: pvremove /dev/sda1
5+
description: match removing physical volume
6+
- test: vgremove vg0
7+
description: match removing volume group
8+
- test: lvremove -f /dev/vg0/lv1
9+
description: match force removing logical volume
10+
- test: pvremove -ff /dev/sda1
11+
description: match force removing physical volume
12+
- test: vgremove -f vg0
13+
description: match force removing volume group
14+
- test: lvcreate -L 10G vg0
15+
description: should not match creating logical volume
16+
- test: pvcreate /dev/sda1
17+
description: should not match creating physical volume
18+
- test: vgcreate vg0 /dev/sda1
19+
description: should not match creating volume group
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
- test: mkfs.ext4 /dev/sda1
3+
description: match formatting a partition with ext4
4+
- test: mkfs.ext3 /dev/sdb2
5+
description: match formatting a partition with ext3
6+
- test: mkfs -t ext4 /dev/sda
7+
description: match formatting entire disk with type parameter
8+
- test: mkfs.fat /dev/mmcblk0p1
9+
description: match formatting SD card partition with FAT
10+
- test: mkfs.xfs /dev/sdc
11+
description: match formatting disk with XFS
12+
- test: mkfs.btrfs /dev/mmcblk0
13+
description: match formatting entire SD card with btrfs
14+
- test: mkfs /tmp/test.img
15+
description: should not match formatting a regular file
16+
- test: mkfs.ext4 /mnt/external
17+
description: should not match formatting a mount point
18+
- test: mkfs.ext4
19+
description: should not match without device parameter

0 commit comments

Comments
 (0)