1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/os
2022-12-02 12:51:10 +02:00
..
bare
cmdline
filelock vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
font vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
notify vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
args.v
const_nix.c.v
const_windows.c.v
const.v
dir_expansions_test.v vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
environment_test.v vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
environment.c.v vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
environment.js.v
fd.c.v
file_test.v all: replace generic <> with [] - part 2 (#16536) 2022-11-26 18:23:26 +02:00
file.c.v all: replace generic <> with [] - part 2 (#16536) 2022-11-26 18:23:26 +02:00
file.js.v
filepath_test.v vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
filepath_windows.v
filepath.v
find_abs_path_of_executable_test.v vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
glob_test.v
inode_test.v vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
inode.c.v
open_uri_default.c.v vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
open_uri_windows.c.v vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
os_android_outside_termux.c.v vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
os_darwin.c.v
os_js.js.v vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
os_linux.c.v
os_nix.c.v vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
os_structs_dirent_default.c.v
os_structs_sigaction_default.c.v
os_structs_stat_default.c.v
os_structs_stat_linux.c.v
os_structs_utsname_default.c.v
os_test.v all: replace generic '<>' with '[]' in error messages and comments (#16571) 2022-12-02 09:22:48 +02:00
os_windows.c.v all: fix dependant->dependent typos, cleanup comments 2022-12-02 12:51:10 +02:00
os.c.v all: replace generic <> with [] - part 2 (#16536) 2022-11-26 18:23:26 +02:00
os.js.v
os.v vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
password_nix.c.v
password_windows.c.v
process_nix.c.v all: fix dependant->dependent typos, cleanup comments 2022-12-02 12:51:10 +02:00
process_test.v vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
process_windows.c.v vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
process.c.v vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
process.js.v vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
process.v vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
README.md
signal_test.v
signal.c.v
signal.js.v vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
signal.v

Description:

os provides common OS/platform independent functions for accessing command line arguments, reading/writing files, listing folders, handling processes etc.


A few os module functions can lead to the TOCTOU vulnerability if used incorrectly. TOCTOU (Time-of-Check-to-Time-of-Use problem) can occur when a file, folder or similar is checked for certain specifications (e.g. read, write permissions) and a change is made afterwards. In the time between the initial check and the edit, an attacker can then cause damage. The following example shows an attack strategy on the left and an improved variant on the right so that TOCTOU is no longer possible.

Example Hint: os.create() opens a file in write-only mode

Possibility for TOCTOU attack
if os.is_writable("file"){

    // >> time to make a quick attack (e.g. symlink /etc/passwd to >file<) <<

    mut f := os.create('path/to/file') ?
        // <do something with file>
    f.close()
}
TOCTOU not possible
mut f := os.create('path/to/file') or {
    println("file not writable")
}

// >> do someting with file; file is locked <<

f.close()

Proven affected functions
The following functions should be used with care and only when used correctly.

  • os.is_readable()
  • os.is_writable()
  • os.is_executable()
  • os.is_link()