Documentation
¶
Index ¶
- Constants
- func GetAttrs(f *os.File) (int32, error)
- func IsAttr(f *os.File, attr int32) (bool, error)
- func SetAttr(f *os.File, attr int32) error
- func UnsetAttr(f *os.File, attr int32) error
- type AttributeTamperAlert
- type Protector
- func (p *Protector) ApplyIncrementalUpdate(ctx context.Context, toAdd, toRemove []string) (*UpdateResult, error)
- func (p *Protector) GetAlerts() <-chan AttributeTamperAlert
- func (p *Protector) GetEvents() <-chan TamperEvent
- func (p *Protector) GetProtectedPaths() []string
- func (p *Protector) IsProtected(path string) bool
- func (p *Protector) StopAll() error
- func (p *Protector) UpdatePaths(ctx context.Context, newPaths []string) (*UpdateResult, error)
- type TamperEvent
- type UpdateResult
Constants ¶
View Source
const ( // from /usr/include/linux/fs.h FS_SECRM_FL = 0x00000001 /* Secure deletion */ FS_UNRM_FL = 0x00000002 /* Undelete */ FS_COMPR_FL = 0x00000004 /* Compress file */ FS_SYNC_FL = 0x00000008 /* Synchronous updates */ FS_IMMUTABLE_FL = 0x00000010 /* Immutable file */ FS_APPEND_FL = 0x00000020 /* writes to file may only append */ FS_NODUMP_FL = 0x00000040 /* do not dump file */ FS_NOATIME_FL = 0x00000080 /* do not update atime */ FS_DIRTY_FL = 0x00000100 FS_COMPRBLK_FL = 0x00000200 /* One or more compressed clusters */ FS_NOCOMP_FL = 0x00000400 /* Don't compress */ FS_ENCRYPT_FL = 0x00000800 /* Encrypted file */ FS_BTREE_FL = 0x00001000 /* btree format dir */ FS_INDEX_FL = 0x00001000 /* hash-indexed directory */ FS_IMAGIC_FL = 0x00002000 /* AFS directory */ FS_JOURNAL_DATA_FL = 0x00004000 /* Reserved for ext3 */ FS_NOTAIL_FL = 0x00008000 /* file tail should not be merged */ FS_DIRSYNC_FL = 0x00010000 /* dirsync behaviour (directories only) */ FS_TOPDIR_FL = 0x00020000 /* Top of directory hierarchies*/ FS_HUGE_FILE_FL = 0x00040000 /* Reserved for ext4 */ FS_EXTENT_FL = 0x00080000 /* Extents */ FS_EA_INODE_FL = 0x00200000 /* Inode used for large EA */ FS_EOFBLOCKS_FL = 0x00400000 /* Reserved for ext4 */ FS_NOCOW_FL = 0x00800000 /* Do not cow file */ FS_INLINE_DATA_FL = 0x10000000 /* Reserved for ext4 */ FS_PROJINHERIT_FL = 0x20000000 /* Create with parents projid */ FS_RESERVED_FL = 0x80000000 /* reserved for ext2 lib */ )
File attributes.
View Source
const ( FS_IOC_GETFLAGS uintptr = 0x80086601 FS_IOC_SETFLAGS uintptr = 0x40086602 )
Request flags.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AttributeTamperAlert ¶
type AttributeTamperAlert struct {
Path string `json:"path"` // 被篡改的路径
Timestamp time.Time `json:"timestamp"` // 检测时间
Details string `json:"details"` // 详细信息(如: "不可变属性被移除")
Restored bool `json:"restored"` // 是否已自动恢复
}
AttributeTamperAlert 属性篡改告警
type Protector ¶
type Protector struct {
// contains filtered or unexported fields
}
Protector 防篡改保护器
func (*Protector) ApplyIncrementalUpdate ¶
func (p *Protector) ApplyIncrementalUpdate(ctx context.Context, toAdd, toRemove []string) (*UpdateResult, error)
ApplyIncrementalUpdate 应用增量更新(服务端已计算好新增和移除) 参数 toAdd: 需要新增保护的目录列表 参数 toRemove: 需要移除保护的目录列表 返回: 更新结果和错误
func (*Protector) GetAlerts ¶
func (p *Protector) GetAlerts() <-chan AttributeTamperAlert
GetAlerts 获取属性篡改告警通道
func (*Protector) GetProtectedPaths ¶
GetProtectedPaths 获取受保护的路径列表
func (*Protector) IsProtected ¶
IsProtected 检查路径是否受保护
func (*Protector) UpdatePaths ¶
UpdatePaths 更新保护的目录列表(保留此方法用于完整配置更新) 参数 newPaths: 新的完整目录列表 返回: 更新结果(新增/移除的目录)和错误
type TamperEvent ¶
type TamperEvent struct {
Path string `json:"path"` // 被修改的路径
Operation string `json:"operation"` // 操作类型: write, remove, rename, chmod
Timestamp time.Time `json:"timestamp"` // 事件时间
Details string `json:"details"` // 详细信息
}
TamperEvent 防篡改事件
type UpdateResult ¶
type UpdateResult struct {
Added []string // 新增保护的目录
Removed []string // 移除保护的目录
Current []string // 当前所有保护的目录
}
UpdateResult 更新结果
Click to show internal directories.
Click to hide internal directories.