Skip to content

Commit

Permalink
Merge branch 'main' into pr/space-techy/845
Browse files Browse the repository at this point in the history
  • Loading branch information
arkid15r committed Mar 2, 2025
2 parents 4bd0594 + efa0ec4 commit 86eed91
Show file tree
Hide file tree
Showing 44 changed files with 1,559 additions and 335 deletions.
22 changes: 22 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
chat:
auto_reply: true
code_generation:
docstrings:
language: en-US
early_access: true
language: en-US
reviews:
assess_linked_issues: true
auto_apply_labels: false
auto_review:
enabled: true
drafts: true
collapse_walkthrough: false
high_level_summary: true
high_level_summary_in_walkthrough: true
labeling_instructions: []
poem: false
profile: chill
request_changes_workflow: false
review_status: true
sequence_diagrams: false
9 changes: 6 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
bug_report.md
---

name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
labels: ['bug']
assignees: ''

---

**Describe the bug**
Expand All @@ -22,7 +23,9 @@ Steps to reproduce the behavior:
A clear and concise description of what you expected to happen.

**Are you going to work on fixing this?**
No.

- [ ] Yes
- [x] No

**Screenshots**
If applicable, add screenshots to help explain your problem.
Expand Down
8 changes: 6 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
labels: ['enhancement']
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
Expand All @@ -16,5 +15,10 @@ A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Are you going to work on implementing this?**

- [ ] Yes
- [x] No

**Additional context**
Add any other context or screenshots about the feature request here.
37 changes: 37 additions & 0 deletions .github/workflows/label-issues.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "Auto Label Issues"
on:
issues:
types:
- edited
- opened

jobs:
label:
runs-on: ubuntu-latest
steps:
- name: Apply Labels to Issues
uses: actions/[email protected]
with:
script: |
const issue = context.payload.issue;
const keywords = {
"bug": ["error", "failure", "not working"],
"enhancement": ["add", "feature request", "improve"],
"question": ["clarification", "help", "how to"]
};
let labels = [];
for (const [label, words] of Object.entries(keywords)) {
if (words.some(word => issue.title.toLowerCase().includes(word) || issue.body.toLowerCase().includes(word))) {
labels.push(label);
}
}
if (labels.length > 0) {
github.rest.issues.addLabels({
issue_number: context.issue.number,
labels: labels,
owner: context.repo.owner,
repo: context.repo.repo
});
}
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ If you are adding new functionality, include relevant test cases.
### 1. Find Something to Work On

- Check the **Issues** tab for open issues: [https://github.com/owasp/nest/issues](https://github.com/owasp/nest/issues)
- If you want to work on something specific, create a new issue or comment on an existing one to let others know.
- Found a bug or have a feature request? Open a new issue.
- Want to work on an existing issue? Ask the maintainers to assign it to you before submitting a pull request.
- New to the project? Start with issues labeled `good first issue` for an easier onboarding experience.

### 2. Create a Branch

Expand Down
15 changes: 14 additions & 1 deletion backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ owasp-process-snapshots:
@echo "Processing OWASP snapshots"
@CMD="python manage.py owasp_process_snapshots" $(MAKE) exec-backend-command

owasp-update-project-health-metrics:
@echo "Updating OWASP project health requirements"
@CMD="python manage.py owasp_update_project_health_metrics" $(MAKE) exec-backend-command

owasp-update-project-health-requirements:
@echo "Updating OWASP project health metrics"
@CMD="python manage.py owasp_update_project_health_requirements" $(MAKE) exec-backend-command

owasp-scrape-chapters:
@echo "Scraping OWASP site chapters data"
@CMD="python manage.py owasp_scrape_chapters" $(MAKE) exec-backend-command
Expand All @@ -90,6 +98,10 @@ owasp-scrape-projects:
@echo "Scraping OWASP site projects data"
@CMD="python manage.py owasp_scrape_projects" $(MAKE) exec-backend-command

owasp-update-events:
@echo "Getting OWASP events data"
@CMD="python manage.py owasp_update_events" $(MAKE) exec-backend-command

purge-data:
@CMD="python manage.py purge_data" $(MAKE) exec-backend-command

Expand Down Expand Up @@ -123,4 +135,5 @@ update-data: \
owasp-scrape-committees \
owasp-scrape-projects \
github-update-project-related-repositories \
owasp-aggregate-projects
owasp-aggregate-projects \
owasp-update-events
8 changes: 8 additions & 0 deletions backend/apps/common/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
"""Common app utils."""

import re
from datetime import datetime, timezone

from django.conf import settings
from django.template.defaultfilters import pluralize
from django.utils.text import Truncator
from django.utils.text import slugify as django_slugify
from humanize import intword, naturaltime


Expand Down Expand Up @@ -35,6 +37,7 @@ def natural_date(value):
value = datetime.strptime(value, "%Y-%m-%d").replace(tzinfo=timezone.utc)
elif isinstance(value, int):
value = datetime.fromtimestamp(value, tz=timezone.utc)

return naturaltime(value)


Expand All @@ -44,6 +47,11 @@ def natural_number(value, unit=None):
return f"{number} {unit}{pluralize(value)}" if unit else number


def slugify(text):
"""Return slug for text."""
return re.sub(r"-{2,}", "-", django_slugify(text))


def truncate(text, limit, truncate="..."):
"""Truncate text to the given limit."""
return Truncator(text).chars(limit, truncate=truncate)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from apps.owasp.constants import OWASP_ORGANIZATION_NAME
from apps.owasp.models.chapter import Chapter
from apps.owasp.models.committee import Committee
from apps.owasp.models.event import Event
from apps.owasp.models.project import Project

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -48,7 +47,6 @@ def handle(self, *_args, **options):

chapters = []
committees = []
events = []
projects = []

offset = options["offset"]
Expand Down Expand Up @@ -84,17 +82,12 @@ def handle(self, *_args, **options):
elif entity_key.startswith("www-project-"):
projects.append(Project.update_data(gh_repository, repository, save=False))

# OWASP events.
elif entity_key.startswith("www-event-"):
events.append(Event.update_data(gh_repository, repository, save=False))

# OWASP committees.
elif entity_key.startswith("www-committee-"):
committees.append(Committee.update_data(gh_repository, repository, save=False))

Chapter.bulk_save(chapters)
Committee.bulk_save(committees)
Event.bulk_save(events)
Project.bulk_save(projects)

# Check repository counts.
Expand Down
2 changes: 1 addition & 1 deletion backend/apps/github/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_repository_path(url):


def normalize_url(url, check_path=False):
"""Normalize GitHub URL."""
"""Normalize URL."""
parsed_url = urlparse(url)
if not parsed_url.netloc or (check_path and not parsed_url.path):
return None
Expand Down
5 changes: 4 additions & 1 deletion backend/apps/owasp/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from apps.owasp.models.committee import Committee
from apps.owasp.models.event import Event
from apps.owasp.models.project import Project
from apps.owasp.models.project_health_metrics import ProjectHealthMetrics
from apps.owasp.models.project_health_requirements import ProjectHealthRequirements
from apps.owasp.models.snapshot import Snapshot


Expand Down Expand Up @@ -63,7 +65,6 @@ class CommitteeAdmin(admin.ModelAdmin):


class EventAdmin(admin.ModelAdmin):
autocomplete_fields = ("owasp_repository",)
list_display = ("name",)
search_fields = ("name",)

Expand Down Expand Up @@ -141,4 +142,6 @@ class SnapshotAdmin(admin.ModelAdmin):
admin.site.register(Committee, CommitteeAdmin)
admin.site.register(Event, EventAdmin)
admin.site.register(Project, ProjectAdmin)
admin.site.register(ProjectHealthMetrics)
admin.site.register(ProjectHealthRequirements)
admin.site.register(Snapshot, SnapshotAdmin)
2 changes: 0 additions & 2 deletions backend/apps/owasp/api/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class Meta:
"name",
"description",
"url",
"created_at",
"updated_at",
)


Expand Down
20 changes: 20 additions & 0 deletions backend/apps/owasp/graphql/nodes/event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""OWASP event GraphQL node."""

from apps.common.graphql.nodes import BaseNode
from apps.owasp.models.event import Event


class EventNode(BaseNode):
"""Event node."""

class Meta:
model = Event
fields = (
"category",
"end_date",
"description",
"key",
"name",
"start_date",
"url",
)
2 changes: 2 additions & 0 deletions backend/apps/owasp/graphql/nodes/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ class ProjectNode(GenericEntityNode):
issues_count = graphene.Int()
key = graphene.String()
languages = graphene.List(graphene.String)
level = graphene.String()
recent_issues = graphene.List(IssueNode)
recent_releases = graphene.List(ReleaseNode)
repositories = graphene.List(RepositoryNode)
repositories_count = graphene.Int()
topics = graphene.List(graphene.String)
type = graphene.String()

class Meta:
model = Project
Expand Down
3 changes: 2 additions & 1 deletion backend/apps/owasp/graphql/queries/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

from .chapter import ChapterQuery
from .committee import CommitteeQuery
from .event import EventQuery
from .project import ProjectQuery
from .stats import StatsQuery


class OwaspQuery(ChapterQuery, CommitteeQuery, ProjectQuery, StatsQuery):
class OwaspQuery(ChapterQuery, CommitteeQuery, EventQuery, ProjectQuery, StatsQuery):
"""OWASP queries."""
17 changes: 17 additions & 0 deletions backend/apps/owasp/graphql/queries/event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""OWASP event GraphQL queries."""

import graphene

from apps.common.graphql.queries import BaseQuery
from apps.owasp.graphql.nodes.event import EventNode
from apps.owasp.models.event import Event


class EventQuery(BaseQuery):
"""Event queries."""

upcoming_events = graphene.List(EventNode)

def resolve_upcoming_events(root, info):
"""Resolve all events."""
return Event.upcoming_events
26 changes: 26 additions & 0 deletions backend/apps/owasp/management/commands/owasp_update_events.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""A command to update OWASP events."""

import yaml
from django.core.management.base import BaseCommand

from apps.github.utils import get_repository_file_content
from apps.owasp.models.event import Event


class Command(BaseCommand):
help = "Import events from the provided YAML file"

def handle(self, *args, **kwargs):
data = yaml.safe_load(
get_repository_file_content(
"https://raw.githubusercontent.com/OWASP/owasp.github.io/main/_data/events.yml"
)
)

Event.bulk_save(
[
Event.update_data(category["category"], event_data)
for category in data
for event_data in category["events"]
]
)
Loading

0 comments on commit 86eed91

Please sign in to comment.