-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'es/6.x' into ccr-6.x
* es/6.x: Fix building Javadoc JARs on JDK for client JARs (#29274) Require JDK 10 to build Elasticsearch (#29174) Decouple NamedXContentRegistry from ElasticsearchException (#29253) Docs: Update generating test coverage reports (#29255) [TEST] Fix issue with HttpInfo passed invalid parameter Remove all dependencies from XContentBuilder (#29225) Fix sporadic failure in CompositeValuesCollectorQueueTests Propagate ignore_unmapped to inner_hits (#29261) TEST: Increase timeout for testPrimaryReplicaResyncFailed REST client: hosts marked dead for the first time should not be immediately retried (#29230) Make SearchStats implement Writeable (#29258) [Docs] Spelling and grammar changes to reindex.asciidoc (#29232) [test] packaging: gradle tasks for groovy tests (#29046) remove testUnassignedShardAndEmptyNodesInRoutingTable Add file permissions checks to precommit task Remove execute mode bit from source files #28745: remove 7.x option in the composite rest tests. Optimize the composite aggregation for match_all and range queries (#28745) Clarify deprecation warning for auto_generate_phrase_query (#29204)
- Loading branch information
Showing
130 changed files
with
3,236 additions
and
1,627 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/FilePermissionsTask.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.elasticsearch.gradle.precommit | ||
|
||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.GradleException | ||
import org.gradle.api.file.FileCollection | ||
import org.gradle.api.tasks.InputFiles | ||
import org.gradle.api.tasks.OutputFile | ||
import org.gradle.api.tasks.SourceSet | ||
import org.gradle.api.tasks.TaskAction | ||
import org.gradle.api.tasks.util.PatternSet | ||
import org.gradle.api.tasks.util.PatternFilterable | ||
import org.apache.tools.ant.taskdefs.condition.Os | ||
|
||
import java.nio.file.Files | ||
import java.nio.file.attribute.PosixFilePermission | ||
import java.nio.file.attribute.PosixFileAttributeView | ||
|
||
import static java.nio.file.attribute.PosixFilePermission.OTHERS_EXECUTE | ||
import static java.nio.file.attribute.PosixFilePermission.GROUP_EXECUTE | ||
import static java.nio.file.attribute.PosixFilePermission.OWNER_EXECUTE | ||
|
||
/** | ||
* Checks source files for correct file permissions. | ||
*/ | ||
public class FilePermissionsTask extends DefaultTask { | ||
|
||
/** A pattern set of which files should be checked. */ | ||
private PatternFilterable filesFilter = new PatternSet() | ||
|
||
@OutputFile | ||
File outputMarker = new File(project.buildDir, 'markers/filePermissions') | ||
|
||
FilePermissionsTask() { | ||
onlyIf { !Os.isFamily(Os.FAMILY_WINDOWS) } | ||
description = "Checks java source files for correct file permissions" | ||
// we always include all source files, and exclude what should not be checked | ||
filesFilter.include('**') | ||
// exclude sh files that might have the executable bit set | ||
filesFilter.exclude('**/*.sh') | ||
} | ||
|
||
/** Returns the files this task will check */ | ||
@InputFiles | ||
FileCollection files() { | ||
List<FileCollection> collections = new ArrayList<>() | ||
for (SourceSet sourceSet : project.sourceSets) { | ||
collections.add(sourceSet.allSource.matching(filesFilter)) | ||
} | ||
return project.files(collections.toArray()) | ||
} | ||
|
||
@TaskAction | ||
void checkInvalidPermissions() { | ||
List<String> failures = new ArrayList<>() | ||
for (File f : files()) { | ||
PosixFileAttributeView fileAttributeView = Files.getFileAttributeView(f.toPath(), PosixFileAttributeView.class) | ||
Set<PosixFilePermission> permissions = fileAttributeView.readAttributes().permissions() | ||
if (permissions.contains(OTHERS_EXECUTE) || permissions.contains(OWNER_EXECUTE) || | ||
permissions.contains(GROUP_EXECUTE)) { | ||
failures.add("Source file is executable: " + f) | ||
} | ||
} | ||
if (failures.isEmpty() == false) { | ||
throw new GradleException('Found invalid file permissions:\n' + failures.join('\n')) | ||
} | ||
outputMarker.setText('done', 'UTF-8') | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.