Closed kadraman closed 4 months ago
@kadraman, thanks for reporting. The session name given on the action run
command line will be used for REST calls made directly from the action (using requests
keyword), although I don't think I've ever explicitly tested this scenario.
The problem in this case is that the fcli
keyword is used to invoke another fcli command like fcli ssc issue count
, and this command isn't aware of the session name that was passed on the action run
command. We need to think about the best way to make any fcli commands invoked from an action aware of the session name with which the action itself was invoked.
Several potential ways to fix this come to mind:
--session
option to any (relevant) fcli
commands invoked from an action. We'd probably need to check whether the command being invoked supports --session
and is in the same module as the action itself; potentially an action could invoke fcli tool
, fcli util
or fcli config
commands that don't accept --session
, or potentially an SSC action could invoke fcli sc-sast
or fcli sc-dast
modules that have their own sessions. We should probably also check that --session
wasn't explicitly specified in fcli
statement in the action file.action run
command execution, set an fcli.env.FCLI_DEFAULT_<module>_SESSION
system property (and potentially unset on action completion) with the given session name; this should be picked up as the default session name for any <module>
commands invoked from the action. See EnvHelper::env()
and FortifyCLIDefaultValueProvider::resolve()
on how such a system property would be resolved as an FCLI_DEFAULT
environment variable.action run
command execution, store the provided session/name as a ThreadLocal
, and have the session framework check whether this ThreadLocal
has a value.I think #2
is easiest to implement, and the session name will be automatically applied to relevant commands in the same module as the action itself only.
Note that this is closely related to #547.
Hey @rsenden . Would adding an optional --<module>-session
option to the action templates be a viable option?
ie: --ssc-session
, --sc-sast-session
, --fod-session
Hi @MikeTheSnowman, until we add full pipeline support (#549), I don't think it will be very common that any action will invoke both fcli ssc
and fcli sc-sast
commands for example, also because actions explicitly live in either ssc
or fod
module and we don't have action support in sc-sast
and sc-dast
modules (yet).
The action run
command currently integrates with standard ssc
/fod
session management, using the same --session
option to specify session name as all other ssc
/fod
commands. For now, I think this is good enough, we only need to implement some mechanism to pass that session/name to other fcli
commands invoked from the action. If there are any actions that do need to invoke sc-sast
commands from an SSC action, the action itself could potentially take a --sc-sast-session
option and explicitly pass that option value to any fcli sc-sast
commands invoked by that action.
Ideally, as described in #551, we'd implement functionality to share sessions between SSC and SC-SAST/SC-DAST modules, which would greatly simplify the ability to invoke commands for all 3 modules (whether or not they all get integrated under the ssc
module) from an action. Then, only actions that do some kind of integration between SSC and FoD would require both an SSC and an FoD session, but this could again be explicitly handled by the action itself,
OK great, yes agreed #2 looks like it would be a good interim solution.
Current Behavior
Running the following action with named session fails as it appears to be looking for
default
session:Expected Behavior
Running with
default
session works:Steps To Reproduce
No response
Environment
Anything else?
No response