Skip to content

Commit 048032f

Browse files
committed
fn change
1 parent 83d9958 commit 048032f

File tree

13 files changed

+146
-0
lines changed

13 files changed

+146
-0
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

jamf/jamfprointegration/helpers.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package helpers
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"path/filepath"
7+
"time"
8+
)
9+
10+
// TODO this duplicated across both integrations. Improve it another time.
11+
12+
// ParseISO8601Date attempts to parse a string date in ISO 8601 format.
13+
func ParseISO8601_Date(dateStr string) (time.Time, error) {
14+
return time.Parse(time.RFC3339, dateStr)
15+
}
16+
17+
// SafeOpenFile opens a file safely after validating and resolving its path.
18+
func SafeOpenFile(filePath string) (*os.File, error) {
19+
cleanPath := filepath.Clean(filePath)
20+
21+
absPath, err := filepath.EvalSymlinks(cleanPath)
22+
if err != nil {
23+
return nil, fmt.Errorf("unable to resolve the absolute path: %s, error: %w", filePath, err)
24+
}
25+
26+
return os.Open(absPath)
27+
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)