{"push_id":2875640120,"size":2,"distinct_size":2,"ref":"refs/heads/fix-top","head":"2138b20a719cf655838d2d97ef12c58e2bf8e24e","before":"68fe61513c79efa0f3f32a1ce6da561c4d58972f","commits":[{"sha":"4598231372e1e2f53e2f31f25abb976a55db6979","author":{"name":"Kir Kolyshkin","email":"3a017b8ddb3f9cf3e4a59978b004111bdeb97f08@gmail.com"},"message":"ContainerTop: harden\n\nIn case a user specifies arguments such as -C or f, optimization\nintroduced by commit a076bad can't be used, so the code falls back\nto listing all the processing and filtering those with PIDs of the\ncontainer specified.\n\nIn case a user also specifies -o with some fields that may contain\nspaces, and those fields are before the PID field (such as -o comm,pid),\nPID filtering is broken. In the worst case scenario, command can\ncontain numeric arguments which are then parsed as PIDs, leading to\nshowing some processes not belonging to the container specified.\n\nTo fix, we need to\n1. Check if ps arguments contain -o. If true:\n2.1. Add pid, to the beginning of -o argument (so the first field is PID).\n2.2. Use the first field to obtain PID for filtering purposes.\n2.3. Remove the first field from the output.\n\nThis fixes two bugs:\n - inability to use -o if it does not contain pid;\n - wrongly listing processes not belonging to a container.\n\nIn addition, now, since we are adding our own PID column, any\ntricks that a malicious user might do with column naming (such\nas adding `-ouid=PID`) won't work anymore, so we can drop\nthe option validation entirely, as well as its test case!\n\nAlas, we have to add another validation, to figure out whether\na user had specified some form of `-o`, so we can add `-o pid`.\nThis came out to be a tricky thing to do, due to ways ps can\nwork with its arguments. Because of that, the unit test case\nis added to validate whether `isCustomFormat()` works as expected.\n\nBig thanks to https://github.com/lifubang for analysis and\npreliminary patches (see https://github.com/moby/moby/pull/37748).\n\nIntegration test comes in the next commit.\n\n[v2: don't add pid if it's the first field already,\n     add pid field even for the first ps (with q) run]\n\n[v3: add o and --format handling, remove validatePSArgs]\n[v4: make sure PID is the first column if we added it]\n[v5: improve error return]\n[v6: check for \"o\" in the middle of the argument]\n[v7: better check for \"o\", added a unit test]\n\nSigned-off-by: Kir Kolyshkin <kolyshkin@gmail.com>","distinct":true,"url":"https://api.github.com/repos/kolyshkin/moby/commits/4598231372e1e2f53e2f31f25abb976a55db6979"},{"sha":"2138b20a719cf655838d2d97ef12c58e2bf8e24e","author":{"name":"Kir Kolyshkin","email":"3a017b8ddb3f9cf3e4a59978b004111bdeb97f08@gmail.com"},"message":"integration/container: Add ContainerTop tests\n\nSigned-off-by: Kir Kolyshkin <kolyshkin@gmail.com>","distinct":true,"url":"https://api.github.com/repos/kolyshkin/moby/commits/2138b20a719cf655838d2d97ef12c58e2bf8e24e"}]}
{"actor":{"display_login":"kolyshkin"}}