コード例 #1
0
    """
	# retrieve the CWE # from the parent directory name
	path = os.getcwd()
	cwe_id = re.search("(CWE\d+)_", os.path.basename(path)).group(1)

	build_name = "toolname.java." + py_common.get_timestamp() + "." + cwe_id

	command1 = "mytool --build " + build_name + " --option1 --option2 " + build_xml_file

	py_common.print_with_timestamp("Running " + command1)
	py_common.run_commands([command1], True)

	command2 = "mytool --analyze " + build_name + " --output " + build_name + ".xml"

	py_common.print_with_timestamp("Running " + command2)
	py_common.run_commands([command2], True)
	"""

    # The code below will just run ant to compile the test cases without using a tool
    # Remove or comment out this code when modifying this file to use an analysis tool
    command = "ant"

    py_common.print_with_timestamp("Running " + command)
    py_common.run_commands([command], True)


if __name__ == '__main__':

    # Analyze the test cases
    py_common.run_analysis("src\\testcases", "build\.xml", run_example_tool)
コード例 #2
0
	where the	batch file exists.
	"""
	
	# In order to run a source code analysis tool, build appropriate command
	# line(s) as shown in the commented out example below
	"""
	build_name = "toolname.c_and_cpp." + py_common.get_timestamp() + "." + bat_file[:-4]

	command1 = "mytool --build " + build_name + " --option1 --option2 " + bat_file

	py_common.print_with_timestamp("Running " + command1)
	py_common.run_commands([command1])

	command2 = "mytool --analyze " + build_name + " --output " + build_name + ".xml"

	py_common.print_with_timestamp("Running " + command2)
	py_common.run_commands([command2])
	"""
  
	# The code below will just run the batch file to compile the test cases without using a tool
	# Remove or comment out this code when modifying this file to use an analysis tool
	command = bat_file

	py_common.print_with_timestamp("Running " + command)
	py_common.run_commands([command])

if __name__ == '__main__':

	# Analyze the test cases
	py_common.run_analysis("testcases", "CWE.*\.bat", run_example_tool)
コード例 #3
0
	where the	batch file exists.
	"""
	
	# In order to run a source code analysis tool, build appropriate command
	# line(s) as shown in the commented out example below
	"""
	build_name = "toolname.c_and_cpp." + py_common.get_timestamp() + "." + bat_file[:-4]

	command1 = "mytool --build " + build_name + " --option1 --option2 " + bat_file

	py_common.print_with_timestamp("Running " + command1)
	py_common.run_commands([command1])

	command2 = "mytool --analyze " + build_name + " --output " + build_name + ".xml"

	py_common.print_with_timestamp("Running " + command2)
	py_common.run_commands([command2])
	"""
  
	# The code below will just run the batch file to compile the test cases without using a tool
	# Remove or comment out this code when modifying this file to use an analysis tool
	command = bat_file

	py_common.print_with_timestamp("Running " + command)
	py_common.run_commands([command])

if __name__ == '__main__':

	# Analyze the test cases
	py_common.run_analysis("testcases", "CWE.*\.bat", run_example_tool)
コード例 #4
0
	# In order to run a source code analysis tool, build appropriate command
	# line(s) as shown in the commented out example below
	"""
	# retrieve the CWE # from the parent directory name
	path = os.getcwd()
	cwe_id = re.search("(CWE\d+)_", os.path.basename(path)).group(1)

	build_name = "toolname.java." + py_common.get_timestamp() + "." + cwe_id

	command1 = "mytool --build " + build_name + " --option1 --option2 " + build_xml_file

	print("Running " + command1)
	py_common.run_commands([command1], True)

	command2 = "mytool --analyze " + build_name + " --output " + build_name + ".xml"

	print("Running " + command2)
	py_common.run_commands([command2], True)
	"""
  
	# The code below will just run ant to compile the test cases without using a tool
	# Remove or comment out this code when modifying this file to use an analysis tool
	command = "ant"

	print("Running " + command)
	py_common.run_commands([command], True)

if __name__ == '__main__':

	py_common.run_analysis("src\\testcases\\*\\build.xml", run_example_tool)
コード例 #5
0
	# line(s) as shown in the commented out example below
	"""
	# retrieve the CWE # from the parent directory name
	path = os.getcwd()
	cwe_id = re.search("(CWE\d+)_", os.path.basename(path)).group(1)

	build_name = "toolname.java." + py_common.get_timestamp() + "." + cwe_id

	command1 = "mytool --build " + build_name + " --option1 --option2 " + build_xml_file

	py_common.print_with_timestamp("Running " + command1)
	py_common.run_commands([command1], True)

	command2 = "mytool --analyze " + build_name + " --output " + build_name + ".xml"

	py_common.print_with_timestamp("Running " + command2)
	py_common.run_commands([command2], True)
	"""
  
	# The code below will just run ant to compile the test cases without using a tool
	# Remove or comment out this code when modifying this file to use an analysis tool
	command = "ant"

	py_common.print_with_timestamp("Running " + command)
	py_common.run_commands([command], True)

if __name__ == '__main__':

	# Analyze the test cases
	py_common.run_analysis("src\\testcases", "build\.xml", run_example_tool)
コード例 #6
0
	py_common.print_with_timestamp("Running " + command2)
	py_common.run_commands([command2])
	"""

    msbuildPath = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe"
    solutionPath = "D:\\GitHub\\MyGit\\JulietTestSuite\\Example\\Example.csproj"
    parameter = "-p:Configuration=Release"

    command1 = msbuildPath + " " + solutionPath + " " + parameter

    py_common.print_with_timestamp("Running " + command1)

    py_common.run_commands([command1])

    # The code below will just run ant to compile the test cases without using a
    # tool
    # Remove or comment out this code when modifying this file to use an analysis
    # tool
    command = bat_file

    py_common.print_with_timestamp("Running " + command)
    py_common.run_commands([command])


if __name__ == '__main__':

    # Analyze the test cases
    py_common.run_analysis(os.path.join("src", "testcases"), "build\.bat",
                           run_example_tool)
コード例 #7
0
    parser = argparse.ArgumentParser(description='A script used to run ' +
                                     TOOL_NAME + ' (C/C++) on various suites.')

    parser.add_argument(
        'suite_path',
        help=
        'The input path to the test case suite to scan (i.e. juliet\\T, juliet\\F, kdm\\T, kdm\\F'
    )
    parser.add_argument(
        'output_path',
        help=
        'path to the output directory (where the tool results will be saved)')
    parser.add_argument(
        'project', help='The name of the project (no spaces) (Suite_01_C)')

    args = parser.parse_args()

    suite_path = args.suite_path
    output_path = args.output_path
    project_prefix = args.project

    # Use full path to output path - this is important as the run_analysis function
    # would use the relative path in the test case directory
    output_path = os.path.abspath(output_path)

    py_common.create_or_clean_directory(output_path)

    # Analyze the test cases
    py_common.run_analysis(suite_path, "CWE.*\.bat", run_fortify_c_cpp)