mirror of
https://github.com/cliffe/SecGen.git
synced 2026-02-22 19:58:03 +00:00
example code: python2 and python3 install modules, script generators and ctf vulnerability/challenge module wrappers
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
# Make pip version available as a fact
|
||||
|
||||
Facter.add("pip_version") do
|
||||
setcode do
|
||||
if Facter::Util::Resolution.which('pip')
|
||||
Facter::Util::Resolution.exec('pip --version 2>&1').match(/^pip (\d+\.\d+\.?\d*).*$/)[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,33 @@
|
||||
# Make python release available as facts
|
||||
|
||||
def get_python_release(executable)
|
||||
if Facter::Util::Resolution.which(executable)
|
||||
results = Facter::Util::Resolution.exec("#{executable} -V 2>&1").match(/^.*(\d+\.\d+)\.\d+\+?$/)
|
||||
if results
|
||||
results[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add("python_release") do
|
||||
setcode do
|
||||
get_python_release 'python'
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add("python2_release") do
|
||||
setcode do
|
||||
default_release = get_python_release 'python'
|
||||
if default_release.nil? or !default_release.start_with?('2')
|
||||
get_python_release 'python2'
|
||||
else
|
||||
default_release
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add("python3_release") do
|
||||
setcode do
|
||||
get_python_release 'python3'
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,33 @@
|
||||
# Make python versions available as facts
|
||||
|
||||
def get_python_version(executable)
|
||||
if Facter::Util::Resolution.which(executable)
|
||||
results = Facter::Util::Resolution.exec("#{executable} -V 2>&1").match(/^.*(\d+\.\d+\.\d+\+?)$/)
|
||||
if results
|
||||
results[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add("python_version") do
|
||||
setcode do
|
||||
get_python_version 'python'
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add("python2_version") do
|
||||
setcode do
|
||||
default_version = get_python_version 'python'
|
||||
if default_version.nil? or !default_version.start_with?('2')
|
||||
get_python_version 'python2'
|
||||
else
|
||||
default_version
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add("python3_version") do
|
||||
setcode do
|
||||
get_python_version 'python3'
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
# Make virtualenv version available as a fact
|
||||
|
||||
Facter.add("virtualenv_version") do
|
||||
setcode do
|
||||
if Facter::Util::Resolution.which('virtualenv')
|
||||
Facter::Util::Resolution.exec('virtualenv --version 2>&1').match(/^(\d+\.\d+\.?\d*).*$/)[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user