#vulnerable code 
                                @Test
    public void canArchiveFileWithSameName() throws Exception {
        WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p");
        p.setDefinition(new CpsFlowDefinition(
                "node {\n" + 
                "  dir ('src') {\n" +
                "   writeFile file: 'hello.txt', text: 'Hello world'\n" +
                "   writeFile file: 'output.zip', text: 'not really a zip'\n" +
                "  }\n" +
                "  dir ('out') {\n" +
                "    zip zipFile: 'output.zip', dir: '../src', glob: '', archive: true\n" +
                "  }\n" +
                "}\n",
                true));
        WorkflowRun run = j.assertBuildStatusSuccess(p.scheduleBuild2(0));
        run = j.assertBuildStatusSuccess(p.scheduleBuild2(0));

        j.assertLogContains("Writing zip file", run);
        assertTrue("Build should have artifacts", run.getHasArtifacts());
        Run<WorkflowJob, WorkflowRun>.Artifact artifact = run.getArtifacts().get(0);
        assertEquals("output.zip", artifact.getFileName());
        VirtualFile file = run.getArtifactManager().root().child(artifact.relativePath);
        ZipInputStream zip = new ZipInputStream(file.open());
        ZipEntry entry = zip.getNextEntry();
        while (entry != null && !entry.getName().equals("output.zip")) {
            System.out.println("zip entry name is: " + entry.getName());
            entry = zip.getNextEntry();
        }
        assertNotNull("output.zip should be included in the zip", entry);
        // we should have the the zip - but double check
        assertEquals("output.zip", entry.getName());
        Scanner scanner = new Scanner(zip);
        assertTrue(scanner.hasNextLine());
        // the file that was not a zip should be included.
        assertEquals("not really a zip", scanner.nextLine());
        zip.close();
    } 
                            #location 28 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                @Test
    public void canArchiveFileWithSameName() throws Exception {
        WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p");
        p.setDefinition(new CpsFlowDefinition(
                "node {\n" + 
                "  dir ('src') {\n" +
                "   writeFile file: 'hello.txt', text: 'Hello world'\n" +
                "   writeFile file: 'output.zip', text: 'not really a zip'\n" +
                "  }\n" +
                "  dir ('out') {\n" +
                "    zip zipFile: 'output.zip', dir: '../src', glob: '', archive: true\n" +
                "  }\n" +
                "}\n",
                true));
        WorkflowRun run = j.assertBuildStatusSuccess(p.scheduleBuild2(0));
        run = j.assertBuildStatusSuccess(p.scheduleBuild2(0));

        j.assertLogContains("Writing zip file", run);
        assertTrue("Build should have artifacts", run.getHasArtifacts());
        Run<WorkflowJob, WorkflowRun>.Artifact artifact = run.getArtifacts().get(0);
        assertEquals("output.zip", artifact.getFileName());
        VirtualFile file = run.getArtifactManager().root().child(artifact.relativePath);
        try (ZipInputStream zip = new ZipInputStream(file.open())) {
            ZipEntry entry = zip.getNextEntry();
            while (entry != null && !entry.getName().equals("output.zip")) {
                System.out.println("zip entry name is: " + entry.getName());
                entry = zip.getNextEntry();
            }
            assertNotNull("output.zip should be included in the zip", entry);
            // we should have the the zip - but double check
            assertEquals("output.zip", entry.getName());
            Scanner scanner = new Scanner(zip);
            assertTrue(scanner.hasNextLine());
            // the file that was not a zip should be included.
            assertEquals("not really a zip", scanner.nextLine());
        }
    }